<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE ScopedTypeVariables #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-comment">-- | Clean out unneeded spill\/reload instructions.</span><span>
</span><span id="line-5"></span><span class="hs-comment">--</span><span>
</span><span id="line-6"></span><span class="hs-comment">--   Handling of join points</span><span>
</span><span id="line-7"></span><span class="hs-comment">--   ~~~~~~~~~~~~~~~~~~~~~~~</span><span>
</span><span id="line-8"></span><span class="hs-comment">--</span><span>
</span><span id="line-9"></span><span class="hs-comment">--   @</span><span>
</span><span id="line-10"></span><span class="hs-comment">--   B1:                          B2:</span><span>
</span><span id="line-11"></span><span class="hs-comment">--    ...                          ...</span><span>
</span><span id="line-12"></span><span class="hs-comment">--       RELOAD SLOT(0), %r1          RELOAD SLOT(0), %r1</span><span>
</span><span id="line-13"></span><span class="hs-comment">--       ... A ...                    ... B ...</span><span>
</span><span id="line-14"></span><span class="hs-comment">--       jump B3                      jump B3</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">--                B3: ... C ...</span><span>
</span><span id="line-17"></span><span class="hs-comment">--                    RELOAD SLOT(0), %r1</span><span>
</span><span id="line-18"></span><span class="hs-comment">--                    ...</span><span>
</span><span id="line-19"></span><span class="hs-comment">--   @</span><span>
</span><span id="line-20"></span><span class="hs-comment">--</span><span>
</span><span id="line-21"></span><span class="hs-comment">--   The Plan</span><span>
</span><span id="line-22"></span><span class="hs-comment">--   ~~~~~~~~</span><span>
</span><span id="line-23"></span><span class="hs-comment">--</span><span>
</span><span id="line-24"></span><span class="hs-comment">--   As long as %r1 hasn't been written to in A, B or C then we don't need</span><span>
</span><span id="line-25"></span><span class="hs-comment">--   the reload in B3.</span><span>
</span><span id="line-26"></span><span class="hs-comment">--</span><span>
</span><span id="line-27"></span><span class="hs-comment">--   What we really care about here is that on the entry to B3, %r1 will</span><span>
</span><span id="line-28"></span><span class="hs-comment">--   always have the same value that is in SLOT(0) (ie, %r1 is _valid_)</span><span>
</span><span id="line-29"></span><span class="hs-comment">--</span><span>
</span><span id="line-30"></span><span class="hs-comment">--   This also works if the reloads in B1\/B2 were spills instead, because</span><span>
</span><span id="line-31"></span><span class="hs-comment">--   spilling %r1 to a slot makes that slot have the same value as %r1.</span><span>
</span><span id="line-32"></span><span class="hs-comment">--</span><span>
</span><span id="line-33"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.CmmToAsm.Reg.Graph.SpillClean</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-34"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanSpills"><span class="hs-identifier">cleanSpills</span></a></span><span>
</span><span id="line-35"></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html"><span class="hs-identifier">GHC.CmmToAsm.Reg.Liveness</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html"><span class="hs-identifier">GHC.CmmToAsm.Instr</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html"><span class="hs-identifier">GHC.Platform.Reg</span></a></span><span>
</span><span id="line-41"></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html"><span class="hs-identifier">GHC.Cmm.BlockId</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.html"><span class="hs-identifier">GHC.Cmm</span></a></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html"><span class="hs-identifier">GHC.Types.Unique.Set</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html"><span class="hs-identifier">GHC.Types.Unique.FM</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html"><span class="hs-identifier">GHC.Types.Unique</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.State.html"><span class="hs-identifier">GHC.Utils.Monad.State</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#"><span class="hs-identifier">GHC.Platform</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Cmm.Dataflow.Collections.html"><span class="hs-identifier">GHC.Cmm.Dataflow.Collections</span></a></span><span>
</span><span id="line-51"></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntSet.html#"><span class="hs-identifier">Data.IntSet</span></a></span><span>              </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.IntSet.Internal.html#IntSet"><span class="hs-identifier">IntSet</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.IntSet.html#"><span class="hs-identifier">Data.IntSet</span></a></span><span>    </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">IntSet</span></span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span class="hs-comment">-- | The identification number of a spill slot.</span><span>
</span><span id="line-59"></span><span class="hs-comment">--   A value is stored in a spill slot when we don't have a free</span><span>
</span><span id="line-60"></span><span class="hs-comment">--   register to hold it.</span><span>
</span><span id="line-61"></span><span class="hs-keyword">type</span><span> </span><span id="Slot"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Slot"><span class="hs-identifier hs-var">Slot</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-62"></span><span>
</span><span id="line-63"></span><span>
</span><span id="line-64"></span><span class="hs-comment">-- | Clean out unneeded spill\/reloads from this top level thing.</span><span>
</span><span id="line-65"></span><span id="local-6989586621681024227"><span id="local-6989586621681024230"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanSpills"><span class="hs-identifier hs-type">cleanSpills</span></a></span><span>
</span><span id="line-66"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024230"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-67"></span><span>        </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span>
</span><span id="line-68"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveCmmDecl"><span class="hs-identifier hs-type">LiveCmmDecl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024227"><span class="hs-identifier hs-type">statics</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024230"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-69"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveCmmDecl"><span class="hs-identifier hs-type">LiveCmmDecl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024227"><span class="hs-identifier hs-type">statics</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024230"><span class="hs-identifier hs-type">instr</span></a></span></span></span><span>
</span><span id="line-70"></span><span>
</span><span id="line-71"></span><span id="cleanSpills"><span class="annot"><span class="annottext">cleanSpills :: forall instr statics.
Instruction instr =&gt;
Platform -&gt; LiveCmmDecl statics instr -&gt; LiveCmmDecl statics instr
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanSpills"><span class="hs-identifier hs-var hs-var">cleanSpills</span></a></span></span><span> </span><span id="local-6989586621681024062"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681024062"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681024061"><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681024061"><span class="hs-identifier hs-var">cmm</span></a></span></span><span>
</span><span id="line-72"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">State CleanS (LiveCmmDecl statics instr)
-&gt; CleanS -&gt; LiveCmmDecl statics instr
forall s a. State s a -&gt; s -&gt; a
</span><a href="GHC.Utils.Monad.State.html#evalState"><span class="hs-identifier hs-var">evalState</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform
-&gt; Int
-&gt; LiveCmmDecl statics instr
-&gt; State CleanS (LiveCmmDecl statics instr)
forall instr statics.
Instruction instr =&gt;
Platform
-&gt; Int
-&gt; LiveCmmDecl statics instr
-&gt; CleanM (LiveCmmDecl statics instr)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanSpin"><span class="hs-identifier hs-var">cleanSpin</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681024062"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681024061"><span class="hs-identifier hs-var">cmm</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#initCleanS"><span class="hs-identifier hs-var">initCleanS</span></a></span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span>
</span><span id="line-75"></span><span class="hs-comment">-- | Do one pass of cleaning.</span><span>
</span><span id="line-76"></span><span id="local-6989586621681024218"><span id="local-6989586621681024219"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanSpin"><span class="hs-identifier hs-type">cleanSpin</span></a></span><span>
</span><span id="line-77"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024219"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-78"></span><span>        </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span>
</span><span id="line-79"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>                              </span><span class="hs-comment">-- ^ Iteration number for the cleaner.</span><span>
</span><span id="line-80"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveCmmDecl"><span class="hs-identifier hs-type">LiveCmmDecl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024218"><span class="hs-identifier hs-type">statics</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024219"><span class="hs-identifier hs-type">instr</span></a></span><span>        </span><span class="hs-comment">-- ^ Liveness annotated code to clean.</span><span>
</span><span id="line-81"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanM"><span class="hs-identifier hs-type">CleanM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveCmmDecl"><span class="hs-identifier hs-type">LiveCmmDecl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024218"><span class="hs-identifier hs-type">statics</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024219"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">)</span></span></span><span>
</span><span id="line-82"></span><span>
</span><span id="line-83"></span><span id="cleanSpin"><span class="annot"><span class="annottext">cleanSpin :: forall instr statics.
Instruction instr =&gt;
Platform
-&gt; Int
-&gt; LiveCmmDecl statics instr
-&gt; CleanM (LiveCmmDecl statics instr)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanSpin"><span class="hs-identifier hs-var hs-var">cleanSpin</span></a></span></span><span> </span><span id="local-6989586621681024032"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681024032"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681024031"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024031"><span class="hs-identifier hs-var">spinCount</span></a></span></span><span> </span><span id="local-6989586621681024030"><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681024030"><span class="hs-identifier hs-var">code</span></a></span></span><span>
</span><span id="line-84"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-85"></span><span>        </span><span class="hs-comment">-- Initialise count of cleaned spill and reload instructions.</span><span>
</span><span id="line-86"></span><span>        </span><span class="annot"><span class="annottext">(CleanS -&gt; CleanS) -&gt; State CleanS ()
forall s. (s -&gt; s) -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#modify"><span class="hs-identifier hs-var">modify</span></a></span><span> </span><span class="annot"><span class="annottext">((CleanS -&gt; CleanS) -&gt; State CleanS ())
-&gt; (CleanS -&gt; CleanS) -&gt; State CleanS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681024028"><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681024028"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681024028"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-87"></span><span>                </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sCleanedSpillsAcc :: Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedSpillsAcc"><span class="hs-identifier hs-var">sCleanedSpillsAcc</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-88"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sCleanedReloadsAcc :: Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedReloadsAcc"><span class="hs-identifier hs-var">sCleanedReloadsAcc</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-89"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sReloadedBy :: UniqFM Store [BlockId]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sReloadedBy"><span class="hs-identifier hs-var">sReloadedBy</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM Store [BlockId]
forall key elt. UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#emptyUFM"><span class="hs-identifier hs-var">emptyUFM</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-90"></span><span>
</span><span id="line-91"></span><span>        </span><span id="local-6989586621681024023"><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681024023"><span class="hs-identifier hs-var">code_forward</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(LiveBasicBlock instr -&gt; State CleanS (LiveBasicBlock instr))
-&gt; LiveCmmDecl statics instr -&gt; CleanM (LiveCmmDecl statics instr)
forall (m :: * -&gt; *) instr statics.
Monad m =&gt;
(LiveBasicBlock instr -&gt; m (LiveBasicBlock instr))
-&gt; LiveCmmDecl statics instr -&gt; m (LiveCmmDecl statics instr)
</span><a href="GHC.CmmToAsm.Reg.Liveness.html#mapBlockTopM"><span class="hs-identifier hs-var">mapBlockTopM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform
-&gt; LiveBasicBlock instr -&gt; State CleanS (LiveBasicBlock instr)
forall instr.
Instruction instr =&gt;
Platform -&gt; LiveBasicBlock instr -&gt; CleanM (LiveBasicBlock instr)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBlockForward"><span class="hs-identifier hs-var">cleanBlockForward</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681024032"><span class="hs-identifier hs-var">platform</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681024030"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-92"></span><span>        </span><span id="local-6989586621681024020"><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681024020"><span class="hs-identifier hs-var">code_backward</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LiveCmmDecl statics instr -&gt; CleanM (LiveCmmDecl statics instr)
forall instr statics.
Instruction instr =&gt;
LiveCmmDecl statics instr -&gt; CleanM (LiveCmmDecl statics instr)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanTopBackward"><span class="hs-identifier hs-var">cleanTopBackward</span></a></span><span> </span><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681024023"><span class="hs-identifier hs-var">code_forward</span></a></span><span>
</span><span id="line-93"></span><span>
</span><span id="line-94"></span><span>        </span><span class="hs-comment">-- During the cleaning of each block we collected information about</span><span>
</span><span id="line-95"></span><span>        </span><span class="hs-comment">-- what regs were valid across each jump. Based on this, work out</span><span>
</span><span id="line-96"></span><span>        </span><span class="hs-comment">-- whether it will be safe to erase reloads after join points for</span><span>
</span><span id="line-97"></span><span>        </span><span class="hs-comment">-- the next pass.</span><span>
</span><span id="line-98"></span><span>        </span><span class="annot"><span class="annottext">State CleanS ()
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#collateJoinPoints"><span class="hs-identifier hs-var">collateJoinPoints</span></a></span><span>
</span><span id="line-99"></span><span>
</span><span id="line-100"></span><span>        </span><span class="hs-comment">-- Remember how many spill and reload instructions we cleaned in this pass.</span><span>
</span><span id="line-101"></span><span>        </span><span id="local-6989586621681024017"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024017"><span class="hs-identifier hs-var">spills</span></a></span></span><span>          </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CleanS -&gt; Int) -&gt; State CleanS Int
forall s a. (s -&gt; a) -&gt; State s a
</span><a href="GHC.Utils.Monad.State.html#gets"><span class="hs-identifier hs-var">gets</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS -&gt; Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedSpillsAcc"><span class="hs-identifier hs-var hs-var">sCleanedSpillsAcc</span></a></span><span>
</span><span id="line-102"></span><span>        </span><span id="local-6989586621681024015"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024015"><span class="hs-identifier hs-var">reloads</span></a></span></span><span>         </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CleanS -&gt; Int) -&gt; State CleanS Int
forall s a. (s -&gt; a) -&gt; State s a
</span><a href="GHC.Utils.Monad.State.html#gets"><span class="hs-identifier hs-var">gets</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS -&gt; Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedReloadsAcc"><span class="hs-identifier hs-var hs-var">sCleanedReloadsAcc</span></a></span><span>
</span><span id="line-103"></span><span>        </span><span class="annot"><span class="annottext">(CleanS -&gt; CleanS) -&gt; State CleanS ()
forall s. (s -&gt; s) -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#modify"><span class="hs-identifier hs-var">modify</span></a></span><span> </span><span class="annot"><span class="annottext">((CleanS -&gt; CleanS) -&gt; State CleanS ())
-&gt; (CleanS -&gt; CleanS) -&gt; State CleanS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681024014"><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681024014"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681024014"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-104"></span><span>                </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sCleanedCount :: [(Int, Int)]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedCount"><span class="hs-identifier hs-var">sCleanedCount</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024017"><span class="hs-identifier hs-var">spills</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024015"><span class="hs-identifier hs-var">reloads</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Int, Int) -&gt; [(Int, Int)] -&gt; [(Int, Int)]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">CleanS -&gt; [(Int, Int)]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedCount"><span class="hs-identifier hs-var hs-var">sCleanedCount</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681024014"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-105"></span><span>
</span><span id="line-106"></span><span>        </span><span class="hs-comment">-- If nothing was cleaned in this pass or the last one</span><span>
</span><span id="line-107"></span><span>        </span><span class="hs-comment">--      then we're done and it's time to bail out.</span><span>
</span><span id="line-108"></span><span>        </span><span id="local-6989586621681024012"><span class="annot"><span class="annottext">[(Int, Int)]
</span><a href="#local-6989586621681024012"><span class="hs-identifier hs-var">cleanedCount</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CleanS -&gt; [(Int, Int)]) -&gt; State CleanS [(Int, Int)]
forall s a. (s -&gt; a) -&gt; State s a
</span><a href="GHC.Utils.Monad.State.html#gets"><span class="hs-identifier hs-var">gets</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS -&gt; [(Int, Int)]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedCount"><span class="hs-identifier hs-var hs-var">sCleanedCount</span></a></span><span>
</span><span id="line-109"></span><span>        </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [(Int, Int)] -&gt; [(Int, Int)]
forall a. Int -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#take"><span class="hs-identifier hs-var">take</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">[(Int, Int)]
</span><a href="#local-6989586621681024012"><span class="hs-identifier hs-var">cleanedCount</span></a></span><span> </span><span class="annot"><span class="annottext">[(Int, Int)] -&gt; [(Int, Int)] -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-110"></span><span>           </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">LiveCmmDecl statics instr -&gt; CleanM (LiveCmmDecl statics instr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681024030"><span class="hs-identifier hs-var">code</span></a></span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span>        </span><span class="hs-comment">-- otherwise go around again</span><span>
</span><span id="line-113"></span><span>           </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Platform
-&gt; Int
-&gt; LiveCmmDecl statics instr
-&gt; CleanM (LiveCmmDecl statics instr)
forall instr statics.
Instruction instr =&gt;
Platform
-&gt; Int
-&gt; LiveCmmDecl statics instr
-&gt; CleanM (LiveCmmDecl statics instr)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanSpin"><span class="hs-identifier hs-var">cleanSpin</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681024032"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681024031"><span class="hs-identifier hs-var">spinCount</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681024020"><span class="hs-identifier hs-var">code_backward</span></a></span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span>
</span><span id="line-116"></span><span class="hs-comment">-------------------------------------------------------------------------------</span><span>
</span><span id="line-117"></span><span class="hs-comment">-- | Clean out unneeded reload instructions,</span><span>
</span><span id="line-118"></span><span class="hs-comment">--   while walking forward over the code.</span><span>
</span><span id="line-119"></span><span id="local-6989586621681024199"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBlockForward"><span class="hs-identifier hs-type">cleanBlockForward</span></a></span><span>
</span><span id="line-120"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024199"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-121"></span><span>        </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span>
</span><span id="line-122"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveBasicBlock"><span class="hs-identifier hs-type">LiveBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024199"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-123"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanM"><span class="hs-identifier hs-type">CleanM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveBasicBlock"><span class="hs-identifier hs-type">LiveBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024199"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-124"></span><span>
</span><span id="line-125"></span><span id="cleanBlockForward"><span class="annot"><span class="annottext">cleanBlockForward :: forall instr.
Instruction instr =&gt;
Platform -&gt; LiveBasicBlock instr -&gt; CleanM (LiveBasicBlock instr)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBlockForward"><span class="hs-identifier hs-var hs-var">cleanBlockForward</span></a></span></span><span> </span><span id="local-6989586621681024004"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681024004"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-type">BasicBlock</span></a></span><span> </span><span id="local-6989586621681024002"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681024002"><span class="hs-identifier hs-var">blockId</span></a></span></span><span> </span><span id="local-6989586621681024001"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681024001"><span class="hs-identifier hs-var">instrs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-126"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-127"></span><span>        </span><span class="hs-comment">-- See if we have a valid association for the entry to this block.</span><span>
</span><span id="line-128"></span><span>        </span><span id="local-6989586621681024000"><span class="annot"><span class="annottext">UniqFM BlockId (Assoc Store)
</span><a href="#local-6989586621681024000"><span class="hs-identifier hs-var">jumpValid</span></a></span></span><span>       </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CleanS -&gt; UniqFM BlockId (Assoc Store))
-&gt; State CleanS (UniqFM BlockId (Assoc Store))
forall s a. (s -&gt; a) -&gt; State s a
</span><a href="GHC.Utils.Monad.State.html#gets"><span class="hs-identifier hs-var">gets</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS -&gt; UniqFM BlockId (Assoc Store)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sJumpValid"><span class="hs-identifier hs-var hs-var">sJumpValid</span></a></span><span>
</span><span id="line-129"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681023997"><span class="annot"><span class="annottext">assoc :: Assoc Store
</span><a href="#local-6989586621681023997"><span class="hs-identifier hs-var hs-var">assoc</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (Assoc Store) -&gt; BlockId -&gt; Maybe (Assoc Store)
forall key elt. Uniquable key =&gt; UniqFM key elt -&gt; key -&gt; Maybe elt
</span><a href="GHC.Types.Unique.FM.html#lookupUFM"><span class="hs-identifier hs-var">lookupUFM</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (Assoc Store)
</span><a href="#local-6989586621681024000"><span class="hs-identifier hs-var">jumpValid</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681024002"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-130"></span><span>                                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681023995"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023995"><span class="hs-identifier hs-var">assoc</span></a></span></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023995"><span class="hs-identifier hs-var">assoc</span></a></span><span>
</span><span id="line-131"></span><span>                                </span><span class="annot"><span class="annottext">Maybe (Assoc Store)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Assoc Store
forall a. Assoc a
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#emptyAssoc"><span class="hs-identifier hs-var">emptyAssoc</span></a></span><span>
</span><span id="line-132"></span><span>
</span><span id="line-133"></span><span>        </span><span id="local-6989586621681023993"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023993"><span class="hs-identifier hs-var">instrs_reload</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
forall instr.
Instruction instr =&gt;
Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-var">cleanForward</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681024004"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681024002"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023997"><span class="hs-identifier hs-var">assoc</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681024001"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-134"></span><span>        </span><span class="annot"><span class="annottext">GenBasicBlock (LiveInstr instr)
-&gt; CleanM (GenBasicBlock (LiveInstr instr))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span>  </span><span class="annot"><span class="annottext">(GenBasicBlock (LiveInstr instr)
 -&gt; CleanM (GenBasicBlock (LiveInstr instr)))
-&gt; GenBasicBlock (LiveInstr instr)
-&gt; CleanM (GenBasicBlock (LiveInstr instr))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; [LiveInstr instr] -&gt; GenBasicBlock (LiveInstr instr)
forall i. BlockId -&gt; [i] -&gt; GenBasicBlock i
</span><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-var">BasicBlock</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681024002"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023993"><span class="hs-identifier hs-var">instrs_reload</span></a></span><span>
</span><span id="line-135"></span><span>
</span><span id="line-136"></span><span>
</span><span id="line-137"></span><span>
</span><span id="line-138"></span><span class="hs-comment">-- | Clean out unneeded reload instructions.</span><span>
</span><span id="line-139"></span><span class="hs-comment">--</span><span>
</span><span id="line-140"></span><span class="hs-comment">--   Walking forwards across the code</span><span>
</span><span id="line-141"></span><span class="hs-comment">--     On a reload, if we know a reg already has the same value as a slot</span><span>
</span><span id="line-142"></span><span class="hs-comment">--     then we don't need to do the reload.</span><span>
</span><span id="line-143"></span><span class="hs-comment">--</span><span>
</span><span id="line-144"></span><span id="local-6989586621681024181"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-type">cleanForward</span></a></span><span>
</span><span id="line-145"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024181"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-146"></span><span>        </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span>
</span><span id="line-147"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span>                  </span><span class="hs-comment">-- ^ the block that we're currently in</span><span>
</span><span id="line-148"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span>              </span><span class="hs-comment">-- ^ two store locations are associated if</span><span>
</span><span id="line-149"></span><span>                                    </span><span class="hs-comment">--     they have the same value</span><span>
</span><span id="line-150"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024181"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span><span>        </span><span class="hs-comment">-- ^ acc</span><span>
</span><span id="line-151"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024181"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span><span>        </span><span class="hs-comment">-- ^ instrs to clean (in backwards order)</span><span>
</span><span id="line-152"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanM"><span class="hs-identifier hs-type">CleanM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024181"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span></span><span> </span><span class="hs-comment">-- ^ cleaned instrs  (in forward   order)</span><span>
</span><span id="line-153"></span><span>
</span><span id="line-154"></span><span id="cleanForward"><span class="annot"><span class="annottext">cleanForward :: forall instr.
Instruction instr =&gt;
Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-var hs-var">cleanForward</span></a></span></span><span> </span><span class="annot"><span class="annottext">Platform
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681023964"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023964"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-155"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr] -&gt; State CleanS [LiveInstr instr]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023964"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-156"></span><span>
</span><span id="line-157"></span><span class="hs-comment">-- Rewrite live range joins via spill slots to just a spill and a reg-reg move</span><span>
</span><span id="line-158"></span><span class="hs-comment">-- hopefully the spill will be also be cleaned in the next pass</span><span>
</span><span id="line-159"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-var">cleanForward</span></a></span><span> </span><span id="local-6989586621681023963"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023963"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681023962"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023962"><span class="hs-identifier hs-var">blockId</span></a></span></span><span> </span><span id="local-6989586621681023961"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023961"><span class="hs-identifier hs-var">assoc</span></a></span></span><span> </span><span id="local-6989586621681023960"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023960"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681023959"><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023959"><span class="hs-identifier hs-var">li1</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681023958"><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023958"><span class="hs-identifier hs-var">li2</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681023957"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023957"><span class="hs-identifier hs-var">instrs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-160"></span><span>
</span><span id="line-161"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#SPILL"><span class="hs-identifier hs-type">SPILL</span></a></span><span>  </span><span id="local-6989586621681023954"><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023954"><span class="hs-identifier hs-var">reg1</span></a></span></span><span>  </span><span id="local-6989586621681023953"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023953"><span class="hs-identifier hs-var">slot1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
</span><span class="hs-identifier">_</span></span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023959"><span class="hs-identifier hs-var">li1</span></a></span><span>
</span><span id="line-162"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#RELOAD"><span class="hs-identifier hs-type">RELOAD</span></a></span><span> </span><span id="local-6989586621681023951"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023951"><span class="hs-identifier hs-var">slot2</span></a></span></span><span> </span><span id="local-6989586621681023950"><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023950"><span class="hs-identifier hs-var">reg2</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="annot"><span class="annottext">Maybe Liveness
</span><span class="hs-identifier">_</span></span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023958"><span class="hs-identifier hs-var">li2</span></a></span><span>
</span><span id="line-163"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023953"><span class="hs-identifier hs-var">slot1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023951"><span class="hs-identifier hs-var">slot2</span></a></span><span>
</span><span id="line-164"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-165"></span><span>                </span><span class="annot"><span class="annottext">(CleanS -&gt; CleanS) -&gt; State CleanS ()
forall s. (s -&gt; s) -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#modify"><span class="hs-identifier hs-var">modify</span></a></span><span> </span><span class="annot"><span class="annottext">((CleanS -&gt; CleanS) -&gt; State CleanS ())
-&gt; (CleanS -&gt; CleanS) -&gt; State CleanS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681023949"><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023949"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023949"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sCleanedReloadsAcc :: Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedReloadsAcc"><span class="hs-identifier hs-var">sCleanedReloadsAcc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CleanS -&gt; Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedReloadsAcc"><span class="hs-identifier hs-var hs-var">sCleanedReloadsAcc</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023949"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-166"></span><span>                </span><span class="annot"><span class="annottext">Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
forall instr.
Instruction instr =&gt;
Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-var">cleanForward</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023963"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023962"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023961"><span class="hs-identifier hs-var">assoc</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023960"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-167"></span><span>                 </span><span class="annot"><span class="annottext">([LiveInstr instr] -&gt; State CleanS [LiveInstr instr])
-&gt; [LiveInstr instr] -&gt; State CleanS [LiveInstr instr]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023959"><span class="hs-identifier hs-var">li1</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInstr instr -&gt; [LiveInstr instr] -&gt; [LiveInstr instr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">InstrSR instr -&gt; Maybe Liveness -&gt; LiveInstr instr
forall instr. InstrSR instr -&gt; Maybe Liveness -&gt; LiveInstr instr
</span><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-var">LiveInstr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Reg -&gt; Reg -&gt; InstrSR instr
forall instr. Instruction instr =&gt; Platform -&gt; Reg -&gt; Reg -&gt; instr
</span><a href="GHC.CmmToAsm.Instr.html#mkRegRegMoveInstr"><span class="hs-identifier hs-var">mkRegRegMoveInstr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023963"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023954"><span class="hs-identifier hs-var">reg1</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023950"><span class="hs-identifier hs-var">reg2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-168"></span><span>                       </span><span class="annot"><span class="annottext">LiveInstr instr -&gt; [LiveInstr instr] -&gt; [LiveInstr instr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023957"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-169"></span><span>
</span><span id="line-170"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-var">cleanForward</span></a></span><span> </span><span id="local-6989586621681023947"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023947"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681023946"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023946"><span class="hs-identifier hs-var">blockId</span></a></span></span><span> </span><span id="local-6989586621681023945"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023945"><span class="hs-identifier hs-var">assoc</span></a></span></span><span> </span><span id="local-6989586621681023944"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023944"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681023943"><span class="annot"><span class="annottext">li :: LiveInstr instr
</span><a href="#local-6989586621681023943"><span class="hs-identifier hs-var">li</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span id="local-6989586621681023942"><span class="annot"><span class="annottext">InstrSR instr
</span><a href="#local-6989586621681023942"><span class="hs-identifier hs-var">i1</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681023941"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023941"><span class="hs-identifier hs-var">instrs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-171"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681023940"><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023940"><span class="hs-identifier hs-var">r1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681023939"><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023939"><span class="hs-identifier hs-var">r2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">InstrSR instr -&gt; Maybe (Reg, Reg)
forall instr. Instruction instr =&gt; instr -&gt; Maybe (Reg, Reg)
</span><a href="GHC.CmmToAsm.Instr.html#takeRegRegMoveInstr"><span class="hs-identifier hs-var">takeRegRegMoveInstr</span></a></span><span> </span><span class="annot"><span class="annottext">InstrSR instr
</span><a href="#local-6989586621681023942"><span class="hs-identifier hs-var">i1</span></a></span><span>
</span><span id="line-172"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023940"><span class="hs-identifier hs-var">r1</span></a></span><span> </span><span class="annot"><span class="annottext">Reg -&gt; Reg -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023939"><span class="hs-identifier hs-var">r2</span></a></span><span>
</span><span id="line-173"></span><span>                </span><span class="hs-comment">-- Erase any left over nop reg reg moves while we're here</span><span>
</span><span id="line-174"></span><span>                </span><span class="hs-comment">-- this will also catch any nop moves that the previous case</span><span>
</span><span id="line-175"></span><span>                </span><span class="hs-comment">-- happens to add.</span><span>
</span><span id="line-176"></span><span>                </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
forall instr.
Instruction instr =&gt;
Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-var">cleanForward</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023947"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023946"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023945"><span class="hs-identifier hs-var">assoc</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023944"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023941"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-177"></span><span>
</span><span id="line-178"></span><span>                </span><span class="hs-comment">-- If r1 has the same value as some slots and we copy r1 to r2,</span><span>
</span><span id="line-179"></span><span>                </span><span class="hs-comment">--      then r2 is now associated with those slots instead</span><span>
</span><span id="line-180"></span><span>                </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681023937"><span class="annot"><span class="annottext">assoc' :: Assoc Store
</span><a href="#local-6989586621681023937"><span class="hs-identifier hs-var hs-var">assoc'</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Store -&gt; Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#addAssoc"><span class="hs-identifier hs-var">addAssoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Reg -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-var">SReg</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023940"><span class="hs-identifier hs-var">r1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Reg -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-var">SReg</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023939"><span class="hs-identifier hs-var">r2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-181"></span><span>                                        </span><span class="annot"><span class="annottext">(Assoc Store -&gt; Assoc Store) -&gt; Assoc Store -&gt; Assoc Store
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#delAssoc"><span class="hs-identifier hs-var">delAssoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Reg -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-var">SReg</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023939"><span class="hs-identifier hs-var">r2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-182"></span><span>                                        </span><span class="annot"><span class="annottext">(Assoc Store -&gt; Assoc Store) -&gt; Assoc Store -&gt; Assoc Store
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023945"><span class="hs-identifier hs-var">assoc</span></a></span><span>
</span><span id="line-183"></span><span>
</span><span id="line-184"></span><span>                        </span><span class="annot"><span class="annottext">Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
forall instr.
Instruction instr =&gt;
Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-var">cleanForward</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023947"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023946"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023937"><span class="hs-identifier hs-var">assoc'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023943"><span class="hs-identifier hs-var">li</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInstr instr -&gt; [LiveInstr instr] -&gt; [LiveInstr instr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023944"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023941"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-185"></span><span>
</span><span id="line-186"></span><span>
</span><span id="line-187"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-var">cleanForward</span></a></span><span> </span><span id="local-6989586621681023933"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023933"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681023932"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023932"><span class="hs-identifier hs-var">blockId</span></a></span></span><span> </span><span id="local-6989586621681023931"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023931"><span class="hs-identifier hs-var">assoc</span></a></span></span><span> </span><span id="local-6989586621681023930"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023930"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681023929"><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023929"><span class="hs-identifier hs-var">li</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681023928"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023928"><span class="hs-identifier hs-var">instrs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-188"></span><span>
</span><span id="line-189"></span><span>        </span><span class="hs-comment">-- Update association due to the spill.</span><span>
</span><span id="line-190"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#SPILL"><span class="hs-identifier hs-type">SPILL</span></a></span><span> </span><span id="local-6989586621681023927"><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023927"><span class="hs-identifier hs-var">reg</span></a></span></span><span> </span><span id="local-6989586621681023926"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023926"><span class="hs-identifier hs-var">slot</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023929"><span class="hs-identifier hs-var">li</span></a></span><span>
</span><span id="line-191"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span>   </span><span id="local-6989586621681023925"><span class="annot"><span class="annottext">assoc' :: Assoc Store
</span><a href="#local-6989586621681023925"><span class="hs-identifier hs-var hs-var">assoc'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Store -&gt; Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#addAssoc"><span class="hs-identifier hs-var">addAssoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Reg -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-var">SReg</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023927"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SSlot"><span class="hs-identifier hs-var">SSlot</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023926"><span class="hs-identifier hs-var">slot</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-192"></span><span>                        </span><span class="annot"><span class="annottext">(Assoc Store -&gt; Assoc Store) -&gt; Assoc Store -&gt; Assoc Store
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#delAssoc"><span class="hs-identifier hs-var">delAssoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SSlot"><span class="hs-identifier hs-var">SSlot</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023926"><span class="hs-identifier hs-var">slot</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-193"></span><span>                        </span><span class="annot"><span class="annottext">(Assoc Store -&gt; Assoc Store) -&gt; Assoc Store -&gt; Assoc Store
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023931"><span class="hs-identifier hs-var">assoc</span></a></span><span>
</span><span id="line-194"></span><span>          </span><span class="hs-keyword">in</span><span>    </span><span class="annot"><span class="annottext">Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
forall instr.
Instruction instr =&gt;
Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-var">cleanForward</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023933"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023932"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023925"><span class="hs-identifier hs-var">assoc'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023929"><span class="hs-identifier hs-var">li</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInstr instr -&gt; [LiveInstr instr] -&gt; [LiveInstr instr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023930"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023928"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-195"></span><span>
</span><span id="line-196"></span><span>        </span><span class="hs-comment">-- Clean a reload instr.</span><span>
</span><span id="line-197"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#RELOAD"><span class="hs-identifier hs-type">RELOAD</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
</span><span class="hs-identifier">_</span></span><span>        </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023929"><span class="hs-identifier hs-var">li</span></a></span><span>
</span><span id="line-198"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681023923"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023923"><span class="hs-identifier hs-var">assoc'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681023922"><span class="annot"><span class="annottext">Maybe (LiveInstr instr)
</span><a href="#local-6989586621681023922"><span class="hs-identifier hs-var">mli</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; LiveInstr instr
-&gt; CleanM (Assoc Store, Maybe (LiveInstr instr))
forall instr.
Instruction instr =&gt;
Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; LiveInstr instr
-&gt; CleanM (Assoc Store, Maybe (LiveInstr instr))
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanReload"><span class="hs-identifier hs-var">cleanReload</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023933"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023932"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023931"><span class="hs-identifier hs-var">assoc</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023929"><span class="hs-identifier hs-var">li</span></a></span><span>
</span><span id="line-199"></span><span>                </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe (LiveInstr instr)
</span><a href="#local-6989586621681023922"><span class="hs-identifier hs-var">mli</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-200"></span><span>                 </span><span class="annot"><span class="annottext">Maybe (LiveInstr instr)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
forall instr.
Instruction instr =&gt;
Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-var">cleanForward</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023933"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023932"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023923"><span class="hs-identifier hs-var">assoc'</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023930"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-201"></span><span>                                                </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023928"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-202"></span><span>
</span><span id="line-203"></span><span>                 </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681023920"><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023920"><span class="hs-identifier hs-var">li'</span></a></span></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
forall instr.
Instruction instr =&gt;
Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-var">cleanForward</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023933"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023932"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023923"><span class="hs-identifier hs-var">assoc'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023920"><span class="hs-identifier hs-var">li'</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInstr instr -&gt; [LiveInstr instr] -&gt; [LiveInstr instr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023930"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-204"></span><span>                                                </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023928"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-205"></span><span>
</span><span id="line-206"></span><span>        </span><span class="hs-comment">-- Remember the association over a jump.</span><span>
</span><span id="line-207"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span id="local-6989586621681023919"><span class="annot"><span class="annottext">InstrSR instr
</span><a href="#local-6989586621681023919"><span class="hs-identifier hs-var">instr</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023929"><span class="hs-identifier hs-var">li</span></a></span><span>
</span><span id="line-208"></span><span>        </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681023918"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681023918"><span class="hs-identifier hs-var">targets</span></a></span></span><span>               </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">InstrSR instr -&gt; [BlockId]
forall instr. Instruction instr =&gt; instr -&gt; [BlockId]
</span><a href="GHC.CmmToAsm.Instr.html#jumpDestsOfInstr"><span class="hs-identifier hs-var">jumpDestsOfInstr</span></a></span><span> </span><span class="annot"><span class="annottext">InstrSR instr
</span><a href="#local-6989586621681023919"><span class="hs-identifier hs-var">instr</span></a></span><span>
</span><span id="line-209"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; Bool -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681023918"><span class="hs-identifier hs-var">targets</span></a></span><span>
</span><span id="line-210"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>    </span><span class="annot"><span class="annottext">(BlockId -&gt; State CleanS ()) -&gt; [BlockId] -&gt; State CleanS ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Assoc Store -&gt; BlockId -&gt; State CleanS ()
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#accJumpValid"><span class="hs-identifier hs-var">accJumpValid</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023931"><span class="hs-identifier hs-var">assoc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681023918"><span class="hs-identifier hs-var">targets</span></a></span><span>
</span><span id="line-211"></span><span>                </span><span class="annot"><span class="annottext">Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
forall instr.
Instruction instr =&gt;
Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-var">cleanForward</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023933"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023932"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023931"><span class="hs-identifier hs-var">assoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023929"><span class="hs-identifier hs-var">li</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInstr instr -&gt; [LiveInstr instr] -&gt; [LiveInstr instr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023930"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023928"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-212"></span><span>
</span><span id="line-213"></span><span>        </span><span class="hs-comment">-- Writing to a reg changes its value.</span><span>
</span><span id="line-214"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span id="local-6989586621681023912"><span class="annot"><span class="annottext">InstrSR instr
</span><a href="#local-6989586621681023912"><span class="hs-identifier hs-var">instr</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023929"><span class="hs-identifier hs-var">li</span></a></span><span>
</span><span id="line-215"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#RU"><span class="hs-identifier hs-type">RU</span></a></span><span> </span><span class="annot"><span class="annottext">[Reg]
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681023910"><span class="annot"><span class="annottext">[Reg]
</span><a href="#local-6989586621681023910"><span class="hs-identifier hs-var">written</span></a></span></span><span>          </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; InstrSR instr -&gt; RegUsage
forall instr. Instruction instr =&gt; Platform -&gt; instr -&gt; RegUsage
</span><a href="GHC.CmmToAsm.Instr.html#regUsageOfInstr"><span class="hs-identifier hs-var">regUsageOfInstr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023933"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">InstrSR instr
</span><a href="#local-6989586621681023912"><span class="hs-identifier hs-var">instr</span></a></span><span>
</span><span id="line-216"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681023906"><span class="annot"><span class="annottext">assoc' :: Assoc Store
</span><a href="#local-6989586621681023906"><span class="hs-identifier hs-var hs-var">assoc'</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Store -&gt; Assoc Store -&gt; Assoc Store)
-&gt; Assoc Store -&gt; [Store] -&gt; Assoc Store
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#delAssoc"><span class="hs-identifier hs-var">delAssoc</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023931"><span class="hs-identifier hs-var">assoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Reg -&gt; Store) -&gt; [Reg] -&gt; [Store]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Reg -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-var">SReg</span></a></span><span> </span><span class="annot"><span class="annottext">([Reg] -&gt; [Store]) -&gt; [Reg] -&gt; [Store]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Reg] -&gt; [Reg]
forall a. Eq a =&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#nub"><span class="hs-identifier hs-var">nub</span></a></span><span> </span><span class="annot"><span class="annottext">[Reg]
</span><a href="#local-6989586621681023910"><span class="hs-identifier hs-var">written</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-217"></span><span>          </span><span class="hs-keyword">in</span><span>  </span><span class="annot"><span class="annottext">Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
forall instr.
Instruction instr =&gt;
Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanForward"><span class="hs-identifier hs-var">cleanForward</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023933"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023932"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023906"><span class="hs-identifier hs-var">assoc'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023929"><span class="hs-identifier hs-var">li</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInstr instr -&gt; [LiveInstr instr] -&gt; [LiveInstr instr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023930"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023928"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-218"></span><span>
</span><span id="line-219"></span><span>
</span><span id="line-220"></span><span>
</span><span id="line-221"></span><span class="hs-comment">-- | Try and rewrite a reload instruction to something more pleasing</span><span>
</span><span id="line-222"></span><span id="local-6989586621681024172"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanReload"><span class="hs-identifier hs-type">cleanReload</span></a></span><span>
</span><span id="line-223"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024172"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-224"></span><span>        </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.Platform.html#Platform"><span class="hs-identifier hs-type">Platform</span></a></span><span>
</span><span id="line-225"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span>
</span><span id="line-226"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span>
</span><span id="line-227"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024172"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-228"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanM"><span class="hs-identifier hs-type">CleanM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024172"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span></span><span>
</span><span id="line-229"></span><span>
</span><span id="line-230"></span><span id="cleanReload"><span class="annot"><span class="annottext">cleanReload :: forall instr.
Instruction instr =&gt;
Platform
-&gt; BlockId
-&gt; Assoc Store
-&gt; LiveInstr instr
-&gt; CleanM (Assoc Store, Maybe (LiveInstr instr))
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanReload"><span class="hs-identifier hs-var hs-var">cleanReload</span></a></span></span><span> </span><span id="local-6989586621681023891"><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023891"><span class="hs-identifier hs-var">platform</span></a></span></span><span> </span><span id="local-6989586621681023890"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023890"><span class="hs-identifier hs-var">blockId</span></a></span></span><span> </span><span id="local-6989586621681023889"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023889"><span class="hs-identifier hs-var">assoc</span></a></span></span><span> </span><span id="local-6989586621681023888"><span class="annot"><span class="annottext">li :: LiveInstr instr
</span><a href="#local-6989586621681023888"><span class="hs-identifier hs-var">li</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#RELOAD"><span class="hs-identifier hs-type">RELOAD</span></a></span><span> </span><span id="local-6989586621681023887"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023887"><span class="hs-identifier hs-var">slot</span></a></span></span><span> </span><span id="local-6989586621681023886"><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023886"><span class="hs-identifier hs-var">reg</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-231"></span><span>
</span><span id="line-232"></span><span>        </span><span class="hs-comment">-- If the reg we're reloading already has the same value as the slot</span><span>
</span><span id="line-233"></span><span>        </span><span class="hs-comment">--      then we can erase the instruction outright.</span><span>
</span><span id="line-234"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Store -&gt; Store -&gt; Assoc Store -&gt; Bool
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#elemAssoc"><span class="hs-identifier hs-var">elemAssoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SSlot"><span class="hs-identifier hs-var">SSlot</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023887"><span class="hs-identifier hs-var">slot</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Reg -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-var">SReg</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023886"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023889"><span class="hs-identifier hs-var">assoc</span></a></span><span>
</span><span id="line-235"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>    </span><span class="annot"><span class="annottext">(CleanS -&gt; CleanS) -&gt; State CleanS ()
forall s. (s -&gt; s) -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#modify"><span class="hs-identifier hs-var">modify</span></a></span><span>  </span><span class="annot"><span class="annottext">((CleanS -&gt; CleanS) -&gt; State CleanS ())
-&gt; (CleanS -&gt; CleanS) -&gt; State CleanS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681023884"><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023884"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023884"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sCleanedReloadsAcc :: Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedReloadsAcc"><span class="hs-identifier hs-var">sCleanedReloadsAcc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CleanS -&gt; Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedReloadsAcc"><span class="hs-identifier hs-var hs-var">sCleanedReloadsAcc</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023884"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-236"></span><span>                </span><span class="annot"><span class="annottext">(Assoc Store, Maybe (LiveInstr instr))
-&gt; CleanM (Assoc Store, Maybe (LiveInstr instr))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023889"><span class="hs-identifier hs-var">assoc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (LiveInstr instr)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-237"></span><span>
</span><span id="line-238"></span><span>        </span><span class="hs-comment">-- If we can find another reg with the same value as this slot then</span><span>
</span><span id="line-239"></span><span>        </span><span class="hs-comment">--      do a move instead of a reload.</span><span>
</span><span id="line-240"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681023883"><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023883"><span class="hs-identifier hs-var">reg2</span></a></span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Assoc Store -&gt; Int -&gt; Maybe Reg
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#findRegOfSlot"><span class="hs-identifier hs-var">findRegOfSlot</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023889"><span class="hs-identifier hs-var">assoc</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023887"><span class="hs-identifier hs-var">slot</span></a></span><span>
</span><span id="line-241"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>    </span><span class="annot"><span class="annottext">(CleanS -&gt; CleanS) -&gt; State CleanS ()
forall s. (s -&gt; s) -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#modify"><span class="hs-identifier hs-var">modify</span></a></span><span> </span><span class="annot"><span class="annottext">((CleanS -&gt; CleanS) -&gt; State CleanS ())
-&gt; (CleanS -&gt; CleanS) -&gt; State CleanS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681023881"><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023881"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023881"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sCleanedReloadsAcc :: Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedReloadsAcc"><span class="hs-identifier hs-var">sCleanedReloadsAcc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CleanS -&gt; Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedReloadsAcc"><span class="hs-identifier hs-var hs-var">sCleanedReloadsAcc</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023881"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-242"></span><span>
</span><span id="line-243"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681023880"><span class="annot"><span class="annottext">assoc' :: Assoc Store
</span><a href="#local-6989586621681023880"><span class="hs-identifier hs-var hs-var">assoc'</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Store -&gt; Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#addAssoc"><span class="hs-identifier hs-var">addAssoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Reg -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-var">SReg</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023886"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Reg -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-var">SReg</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023883"><span class="hs-identifier hs-var">reg2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-244"></span><span>                                </span><span class="annot"><span class="annottext">(Assoc Store -&gt; Assoc Store) -&gt; Assoc Store -&gt; Assoc Store
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#delAssoc"><span class="hs-identifier hs-var">delAssoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Reg -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-var">SReg</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023886"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-245"></span><span>                                </span><span class="annot"><span class="annottext">(Assoc Store -&gt; Assoc Store) -&gt; Assoc Store -&gt; Assoc Store
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023889"><span class="hs-identifier hs-var">assoc</span></a></span><span>
</span><span id="line-246"></span><span>
</span><span id="line-247"></span><span>                </span><span class="annot"><span class="annottext">(Assoc Store, Maybe (LiveInstr instr))
-&gt; CleanM (Assoc Store, Maybe (LiveInstr instr))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023880"><span class="hs-identifier hs-var">assoc'</span></a></span><span>
</span><span id="line-248"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LiveInstr instr -&gt; Maybe (LiveInstr instr)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(LiveInstr instr -&gt; Maybe (LiveInstr instr))
-&gt; LiveInstr instr -&gt; Maybe (LiveInstr instr)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">InstrSR instr -&gt; Maybe Liveness -&gt; LiveInstr instr
forall instr. InstrSR instr -&gt; Maybe Liveness -&gt; LiveInstr instr
</span><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-var">LiveInstr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Platform -&gt; Reg -&gt; Reg -&gt; InstrSR instr
forall instr. Instruction instr =&gt; Platform -&gt; Reg -&gt; Reg -&gt; instr
</span><a href="GHC.CmmToAsm.Instr.html#mkRegRegMoveInstr"><span class="hs-identifier hs-var">mkRegRegMoveInstr</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681023891"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023883"><span class="hs-identifier hs-var">reg2</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023886"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-249"></span><span>
</span><span id="line-250"></span><span>        </span><span class="hs-comment">-- Gotta keep this instr.</span><span>
</span><span id="line-251"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-252"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>    </span><span class="hs-comment">-- Update the association.</span><span>
</span><span id="line-253"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681023879"><span class="annot"><span class="annottext">assoc' :: Assoc Store
</span><a href="#local-6989586621681023879"><span class="hs-identifier hs-var hs-var">assoc'</span></a></span></span><span>
</span><span id="line-254"></span><span>                        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Store -&gt; Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#addAssoc"><span class="hs-identifier hs-var">addAssoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Reg -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-var">SReg</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023886"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">)</span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SSlot"><span class="hs-identifier hs-var">SSlot</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023887"><span class="hs-identifier hs-var">slot</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-255"></span><span>                                </span><span class="hs-comment">-- doing the reload makes reg and slot the same value</span><span>
</span><span id="line-256"></span><span>                        </span><span class="annot"><span class="annottext">(Assoc Store -&gt; Assoc Store) -&gt; Assoc Store -&gt; Assoc Store
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#delAssoc"><span class="hs-identifier hs-var">delAssoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Reg -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-var">SReg</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023886"><span class="hs-identifier hs-var">reg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-257"></span><span>                                </span><span class="hs-comment">-- reg value changes on reload</span><span>
</span><span id="line-258"></span><span>                        </span><span class="annot"><span class="annottext">(Assoc Store -&gt; Assoc Store) -&gt; Assoc Store -&gt; Assoc Store
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023889"><span class="hs-identifier hs-var">assoc</span></a></span><span>
</span><span id="line-259"></span><span>
</span><span id="line-260"></span><span>                </span><span class="hs-comment">-- Remember that this block reloads from this slot.</span><span>
</span><span id="line-261"></span><span>                </span><span class="annot"><span class="annottext">BlockId -&gt; Int -&gt; State CleanS ()
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#accBlockReloadsSlot"><span class="hs-identifier hs-var">accBlockReloadsSlot</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023890"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023887"><span class="hs-identifier hs-var">slot</span></a></span><span>
</span><span id="line-262"></span><span>
</span><span id="line-263"></span><span>                </span><span class="annot"><span class="annottext">(Assoc Store, Maybe (LiveInstr instr))
-&gt; CleanM (Assoc Store, Maybe (LiveInstr instr))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023879"><span class="hs-identifier hs-var">assoc'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LiveInstr instr -&gt; Maybe (LiveInstr instr)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023888"><span class="hs-identifier hs-var">li</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-264"></span><span>
</span><span id="line-265"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanReload"><span class="hs-identifier hs-var">cleanReload</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-266"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; CleanM (Assoc Store, Maybe (LiveInstr instr))
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;RegSpillClean.cleanReload: unhandled instr&quot;</span></span><span>
</span><span id="line-267"></span><span>
</span><span id="line-268"></span><span>
</span><span id="line-269"></span><span class="hs-comment">-------------------------------------------------------------------------------</span><span>
</span><span id="line-270"></span><span class="hs-comment">-- | Clean out unneeded spill instructions,</span><span>
</span><span id="line-271"></span><span class="hs-comment">--   while walking backwards over the code.</span><span>
</span><span id="line-272"></span><span class="hs-comment">--</span><span>
</span><span id="line-273"></span><span class="hs-comment">--      If there were no reloads from a slot between a spill and the last one</span><span>
</span><span id="line-274"></span><span class="hs-comment">--      then the slot was never read and we don't need the spill.</span><span>
</span><span id="line-275"></span><span class="hs-comment">--</span><span>
</span><span id="line-276"></span><span class="hs-comment">--      SPILL   r0 -&gt; s1</span><span>
</span><span id="line-277"></span><span class="hs-comment">--      RELOAD  s1 -&gt; r2</span><span>
</span><span id="line-278"></span><span class="hs-comment">--      SPILL   r3 -&gt; s1        &lt;--- don't need this spill</span><span>
</span><span id="line-279"></span><span class="hs-comment">--      SPILL   r4 -&gt; s1</span><span>
</span><span id="line-280"></span><span class="hs-comment">--      RELOAD  s1 -&gt; r5</span><span>
</span><span id="line-281"></span><span class="hs-comment">--</span><span>
</span><span id="line-282"></span><span class="hs-comment">--      Maintain a set of</span><span>
</span><span id="line-283"></span><span class="hs-comment">--              &quot;slots which were spilled to but not reloaded from yet&quot;</span><span>
</span><span id="line-284"></span><span class="hs-comment">--</span><span>
</span><span id="line-285"></span><span class="hs-comment">--      Walking backwards across the code:</span><span>
</span><span id="line-286"></span><span class="hs-comment">--       a) On a reload from a slot, remove it from the set.</span><span>
</span><span id="line-287"></span><span class="hs-comment">--</span><span>
</span><span id="line-288"></span><span class="hs-comment">--       a) On a spill from a slot</span><span>
</span><span id="line-289"></span><span class="hs-comment">--              If the slot is in set then we can erase the spill,</span><span>
</span><span id="line-290"></span><span class="hs-comment">--               because it won't be reloaded from until after the next spill.</span><span>
</span><span id="line-291"></span><span class="hs-comment">--</span><span>
</span><span id="line-292"></span><span class="hs-comment">--              otherwise</span><span>
</span><span id="line-293"></span><span class="hs-comment">--               keep the spill and add the slot to the set</span><span>
</span><span id="line-294"></span><span class="hs-comment">--</span><span>
</span><span id="line-295"></span><span class="hs-comment">-- TODO: This is mostly inter-block</span><span>
</span><span id="line-296"></span><span class="hs-comment">--       we should really be updating the noReloads set as we cross jumps also.</span><span>
</span><span id="line-297"></span><span class="hs-comment">--</span><span>
</span><span id="line-298"></span><span class="hs-comment">-- TODO: generate noReloads from liveSlotsOnEntry</span><span>
</span><span id="line-299"></span><span class="hs-comment">--</span><span>
</span><span id="line-300"></span><span id="local-6989586621681024197"><span id="local-6989586621681024198"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanTopBackward"><span class="hs-identifier hs-type">cleanTopBackward</span></a></span><span>
</span><span id="line-301"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024198"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-302"></span><span>        </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveCmmDecl"><span class="hs-identifier hs-type">LiveCmmDecl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024197"><span class="hs-identifier hs-type">statics</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024198"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-303"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanM"><span class="hs-identifier hs-type">CleanM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveCmmDecl"><span class="hs-identifier hs-type">LiveCmmDecl</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024197"><span class="hs-identifier hs-type">statics</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024198"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">)</span></span></span><span>
</span><span id="line-304"></span><span>
</span><span id="line-305"></span><span id="cleanTopBackward"><span class="annot"><span class="annottext">cleanTopBackward :: forall instr statics.
Instruction instr =&gt;
LiveCmmDecl statics instr -&gt; CleanM (LiveCmmDecl statics instr)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanTopBackward"><span class="hs-identifier hs-var hs-var">cleanTopBackward</span></a></span></span><span> </span><span id="local-6989586621681023867"><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681023867"><span class="hs-identifier hs-var">cmm</span></a></span></span><span>
</span><span id="line-306"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681023867"><span class="hs-identifier hs-var">cmm</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-307"></span><span>        </span><span class="annot"><a href="GHC.Cmm.html#CmmData"><span class="hs-identifier hs-type">CmmData</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span>
</span><span id="line-308"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">LiveCmmDecl statics instr -&gt; CleanM (LiveCmmDecl statics instr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">LiveCmmDecl statics instr
</span><a href="#local-6989586621681023867"><span class="hs-identifier hs-var">cmm</span></a></span><span>
</span><span id="line-309"></span><span>
</span><span id="line-310"></span><span>        </span><span class="annot"><a href="GHC.Cmm.html#CmmProc"><span class="hs-identifier hs-type">CmmProc</span></a></span><span> </span><span id="local-6989586621681023864"><span class="annot"><span class="annottext">LiveInfo
</span><a href="#local-6989586621681023864"><span class="hs-identifier hs-var">info</span></a></span></span><span> </span><span id="local-6989586621681023863"><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681023863"><span class="hs-keyword hs-var">label</span></a></span></span><span> </span><span id="local-6989586621681023862"><span class="annot"><span class="annottext">[GlobalReg]
</span><a href="#local-6989586621681023862"><span class="hs-identifier hs-var">live</span></a></span></span><span> </span><span id="local-6989586621681023861"><span class="annot"><span class="annottext">[SCC (LiveBasicBlock instr)]
</span><a href="#local-6989586621681023861"><span class="hs-identifier hs-var">sccs</span></a></span></span><span>
</span><span id="line-311"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInfo"><span class="hs-identifier hs-type">LiveInfo</span></a></span><span> </span><span class="annot"><span class="annottext">LabelMap RawCmmStatics
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">BlockMap RegSet
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681023859"><span class="annot"><span class="annottext">BlockMap IntSet
</span><a href="#local-6989586621681023859"><span class="hs-identifier hs-var">liveSlotsOnEntry</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LiveInfo
</span><a href="#local-6989586621681023864"><span class="hs-identifier hs-var">info</span></a></span><span>
</span><span id="line-312"></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>  </span><span id="local-6989586621681023858"><span class="annot"><span class="annottext">[SCC (LiveBasicBlock instr)]
</span><a href="#local-6989586621681023858"><span class="hs-identifier hs-var">sccs'</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(SCC (LiveBasicBlock instr)
 -&gt; State CleanS (SCC (LiveBasicBlock instr)))
-&gt; [SCC (LiveBasicBlock instr)]
-&gt; State CleanS [SCC (LiveBasicBlock instr)]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(LiveBasicBlock instr -&gt; State CleanS (LiveBasicBlock instr))
-&gt; SCC (LiveBasicBlock instr)
-&gt; State CleanS (SCC (LiveBasicBlock instr))
forall (m :: * -&gt; *) a b.
Monad m =&gt;
(a -&gt; m b) -&gt; SCC a -&gt; m (SCC b)
</span><a href="GHC.CmmToAsm.Reg.Liveness.html#mapSCCM"><span class="hs-identifier hs-var">mapSCCM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BlockMap IntSet
-&gt; LiveBasicBlock instr -&gt; State CleanS (LiveBasicBlock instr)
forall instr.
Instruction instr =&gt;
BlockMap IntSet
-&gt; LiveBasicBlock instr -&gt; CleanM (LiveBasicBlock instr)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBlockBackward"><span class="hs-identifier hs-var">cleanBlockBackward</span></a></span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
</span><a href="#local-6989586621681023859"><span class="hs-identifier hs-var">liveSlotsOnEntry</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[SCC (LiveBasicBlock instr)]
</span><a href="#local-6989586621681023861"><span class="hs-identifier hs-var">sccs</span></a></span><span>
</span><span id="line-313"></span><span>                </span><span class="annot"><span class="annottext">LiveCmmDecl statics instr -&gt; CleanM (LiveCmmDecl statics instr)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span>  </span><span class="annot"><span class="annottext">(LiveCmmDecl statics instr -&gt; CleanM (LiveCmmDecl statics instr))
-&gt; LiveCmmDecl statics instr -&gt; CleanM (LiveCmmDecl statics instr)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInfo
-&gt; CLabel
-&gt; [GlobalReg]
-&gt; [SCC (LiveBasicBlock instr)]
-&gt; LiveCmmDecl statics instr
forall d h g. h -&gt; CLabel -&gt; [GlobalReg] -&gt; g -&gt; GenCmmDecl d h g
</span><a href="GHC.Cmm.html#CmmProc"><span class="hs-identifier hs-var">CmmProc</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInfo
</span><a href="#local-6989586621681023864"><span class="hs-identifier hs-var">info</span></a></span><span> </span><span class="annot"><span class="annottext">CLabel
</span><a href="#local-6989586621681023863"><span class="hs-keyword hs-var">label</span></a></span><span> </span><span class="annot"><span class="annottext">[GlobalReg]
</span><a href="#local-6989586621681023862"><span class="hs-identifier hs-var">live</span></a></span><span> </span><span class="annot"><span class="annottext">[SCC (LiveBasicBlock instr)]
</span><a href="#local-6989586621681023858"><span class="hs-identifier hs-var">sccs'</span></a></span><span>
</span><span id="line-314"></span><span>
</span><span id="line-315"></span><span>
</span><span id="line-316"></span><span id="local-6989586621681024139"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBlockBackward"><span class="hs-identifier hs-type">cleanBlockBackward</span></a></span><span>
</span><span id="line-317"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024139"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-318"></span><span>        </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#BlockMap"><span class="hs-identifier hs-type">BlockMap</span></a></span><span> </span><span class="annot"><a href="../../containers/src/Data.IntSet.Internal.html#IntSet"><span class="hs-identifier hs-type">IntSet</span></a></span><span>
</span><span id="line-319"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveBasicBlock"><span class="hs-identifier hs-type">LiveBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024139"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-320"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanM"><span class="hs-identifier hs-type">CleanM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveBasicBlock"><span class="hs-identifier hs-type">LiveBasicBlock</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024139"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-321"></span><span>
</span><span id="line-322"></span><span id="cleanBlockBackward"><span class="annot"><span class="annottext">cleanBlockBackward :: forall instr.
Instruction instr =&gt;
BlockMap IntSet
-&gt; LiveBasicBlock instr -&gt; CleanM (LiveBasicBlock instr)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBlockBackward"><span class="hs-identifier hs-var hs-var">cleanBlockBackward</span></a></span></span><span> </span><span id="local-6989586621681023850"><span class="annot"><span class="annottext">BlockMap IntSet
</span><a href="#local-6989586621681023850"><span class="hs-identifier hs-var">liveSlotsOnEntry</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-type">BasicBlock</span></a></span><span> </span><span id="local-6989586621681023849"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023849"><span class="hs-identifier hs-var">blockId</span></a></span></span><span> </span><span id="local-6989586621681023848"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023848"><span class="hs-identifier hs-var">instrs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-323"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>   </span><span id="local-6989586621681023847"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023847"><span class="hs-identifier hs-var">instrs_spill</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
forall instr.
Instruction instr =&gt;
BlockMap IntSet
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBackward"><span class="hs-identifier hs-var">cleanBackward</span></a></span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
</span><a href="#local-6989586621681023850"><span class="hs-identifier hs-var">liveSlotsOnEntry</span></a></span><span>  </span><span class="annot"><span class="annottext">UniqSet Int
forall a. UniqSet a
</span><a href="GHC.Types.Unique.Set.html#emptyUniqSet"><span class="hs-identifier hs-var">emptyUniqSet</span></a></span><span>  </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023848"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-324"></span><span>        </span><span class="annot"><span class="annottext">GenBasicBlock (LiveInstr instr)
-&gt; CleanM (GenBasicBlock (LiveInstr instr))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span>  </span><span class="annot"><span class="annottext">(GenBasicBlock (LiveInstr instr)
 -&gt; CleanM (GenBasicBlock (LiveInstr instr)))
-&gt; GenBasicBlock (LiveInstr instr)
-&gt; CleanM (GenBasicBlock (LiveInstr instr))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; [LiveInstr instr] -&gt; GenBasicBlock (LiveInstr instr)
forall i. BlockId -&gt; [i] -&gt; GenBasicBlock i
</span><a href="GHC.Cmm.html#BasicBlock"><span class="hs-identifier hs-var">BasicBlock</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023849"><span class="hs-identifier hs-var">blockId</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023847"><span class="hs-identifier hs-var">instrs_spill</span></a></span><span>
</span><span id="line-325"></span><span>
</span><span id="line-326"></span><span>
</span><span id="line-327"></span><span>
</span><span id="line-328"></span><span id="local-6989586621681024132"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBackward"><span class="hs-identifier hs-type">cleanBackward</span></a></span><span>
</span><span id="line-329"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024132"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-330"></span><span>        </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#BlockMap"><span class="hs-identifier hs-type">BlockMap</span></a></span><span> </span><span class="annot"><a href="../../containers/src/Data.IntSet.Internal.html#IntSet"><span class="hs-identifier hs-type">IntSet</span></a></span><span>          </span><span class="hs-comment">-- ^ Slots live on entry to each block</span><span>
</span><span id="line-331"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html#UniqSet"><span class="hs-identifier hs-type">UniqSet</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>              </span><span class="hs-comment">-- ^ Slots that have been spilled, but not reloaded from</span><span>
</span><span id="line-332"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024132"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span><span>        </span><span class="hs-comment">-- ^ acc</span><span>
</span><span id="line-333"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024132"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span><span>        </span><span class="hs-comment">-- ^ Instrs to clean (in forwards order)</span><span>
</span><span id="line-334"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanM"><span class="hs-identifier hs-type">CleanM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024132"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span></span><span> </span><span class="hs-comment">-- ^ Cleaned instrs  (in backwards order)</span><span>
</span><span id="line-335"></span><span>
</span><span id="line-336"></span><span id="cleanBackward"><span class="annot"><span class="annottext">cleanBackward :: forall instr.
Instruction instr =&gt;
BlockMap IntSet
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBackward"><span class="hs-identifier hs-var hs-var">cleanBackward</span></a></span></span><span> </span><span id="local-6989586621681023841"><span class="annot"><span class="annottext">BlockMap IntSet
</span><a href="#local-6989586621681023841"><span class="hs-identifier hs-var">liveSlotsOnEntry</span></a></span></span><span> </span><span id="local-6989586621681023840"><span class="annot"><span class="annottext">UniqSet Int
</span><a href="#local-6989586621681023840"><span class="hs-identifier hs-var">noReloads</span></a></span></span><span> </span><span id="local-6989586621681023839"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023839"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span id="local-6989586621681023838"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023838"><span class="hs-identifier hs-var">lis</span></a></span></span><span>
</span><span id="line-337"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>   </span><span id="local-6989586621681023837"><span class="annot"><span class="annottext">UniqFM Store [BlockId]
</span><a href="#local-6989586621681023837"><span class="hs-identifier hs-var">reloadedBy</span></a></span></span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(CleanS -&gt; UniqFM Store [BlockId])
-&gt; State CleanS (UniqFM Store [BlockId])
forall s a. (s -&gt; a) -&gt; State s a
</span><a href="GHC.Utils.Monad.State.html#gets"><span class="hs-identifier hs-var">gets</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS -&gt; UniqFM Store [BlockId]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sReloadedBy"><span class="hs-identifier hs-var hs-var">sReloadedBy</span></a></span><span>
</span><span id="line-338"></span><span>        </span><span class="annot"><span class="annottext">BlockMap IntSet
-&gt; UniqFM Store [BlockId]
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
forall instr.
Instruction instr =&gt;
BlockMap IntSet
-&gt; UniqFM Store [BlockId]
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBackward%27"><span class="hs-identifier hs-var">cleanBackward'</span></a></span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
</span><a href="#local-6989586621681023841"><span class="hs-identifier hs-var">liveSlotsOnEntry</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM Store [BlockId]
</span><a href="#local-6989586621681023837"><span class="hs-identifier hs-var">reloadedBy</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Int
</span><a href="#local-6989586621681023840"><span class="hs-identifier hs-var">noReloads</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023839"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023838"><span class="hs-identifier hs-var">lis</span></a></span><span>
</span><span id="line-339"></span><span>
</span><span id="line-340"></span><span>
</span><span id="line-341"></span><span id="local-6989586621681024129"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBackward%27"><span class="hs-identifier hs-type">cleanBackward'</span></a></span><span>
</span><span id="line-342"></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Instr.html#Instruction"><span class="hs-identifier hs-type">Instruction</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024129"><span class="hs-identifier hs-type">instr</span></a></span><span>
</span><span id="line-343"></span><span>        </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#BlockMap"><span class="hs-identifier hs-type">BlockMap</span></a></span><span> </span><span class="annot"><a href="../../containers/src/Data.IntSet.Internal.html#IntSet"><span class="hs-identifier hs-type">IntSet</span></a></span><span>
</span><span id="line-344"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html#UniqFM"><span class="hs-identifier hs-type">UniqFM</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-345"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html#UniqSet"><span class="hs-identifier hs-type">UniqSet</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-346"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024129"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-347"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024129"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-348"></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.State.html#State"><span class="hs-identifier hs-type">State</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanS"><span class="hs-identifier hs-type">CleanS</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024129"><span class="hs-identifier hs-type">instr</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-349"></span><span>
</span><span id="line-350"></span><span id="cleanBackward%27"><span class="annot"><span class="annottext">cleanBackward' :: forall instr.
Instruction instr =&gt;
BlockMap IntSet
-&gt; UniqFM Store [BlockId]
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBackward%27"><span class="hs-identifier hs-var hs-var">cleanBackward'</span></a></span></span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">UniqFM Store [BlockId]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">UniqSet Int
</span><span class="hs-identifier">_</span></span><span>      </span><span id="local-6989586621681023817"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023817"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-351"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr] -&gt; State CleanS [LiveInstr instr]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span>  </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023817"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-352"></span><span>
</span><span id="line-353"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBackward%27"><span class="hs-identifier hs-var">cleanBackward'</span></a></span><span> </span><span id="local-6989586621681023816"><span class="annot"><span class="annottext">BlockMap IntSet
</span><a href="#local-6989586621681023816"><span class="hs-identifier hs-var">liveSlotsOnEntry</span></a></span></span><span> </span><span id="local-6989586621681023815"><span class="annot"><span class="annottext">UniqFM Store [BlockId]
</span><a href="#local-6989586621681023815"><span class="hs-identifier hs-var">reloadedBy</span></a></span></span><span> </span><span id="local-6989586621681023814"><span class="annot"><span class="annottext">UniqSet Int
</span><a href="#local-6989586621681023814"><span class="hs-identifier hs-var">noReloads</span></a></span></span><span> </span><span id="local-6989586621681023813"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023813"><span class="hs-identifier hs-var">acc</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681023812"><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023812"><span class="hs-identifier hs-var">li</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681023811"><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023811"><span class="hs-identifier hs-var">instrs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-354"></span><span>
</span><span id="line-355"></span><span>        </span><span class="hs-comment">-- If nothing ever reloads from this slot then we don't need the spill.</span><span>
</span><span id="line-356"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#SPILL"><span class="hs-identifier hs-type">SPILL</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681023810"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023810"><span class="hs-identifier hs-var">slot</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
</span><span class="hs-identifier">_</span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023812"><span class="hs-identifier hs-var">li</span></a></span><span>
</span><span id="line-357"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe [BlockId]
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>       </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UniqFM Store [BlockId] -&gt; Store -&gt; Maybe [BlockId]
forall key elt. Uniquable key =&gt; UniqFM key elt -&gt; key -&gt; Maybe elt
</span><a href="GHC.Types.Unique.FM.html#lookupUFM"><span class="hs-identifier hs-var">lookupUFM</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM Store [BlockId]
</span><a href="#local-6989586621681023815"><span class="hs-identifier hs-var">reloadedBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SSlot"><span class="hs-identifier hs-var">SSlot</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023810"><span class="hs-identifier hs-var">slot</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-358"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>    </span><span class="annot"><span class="annottext">(CleanS -&gt; CleanS) -&gt; State CleanS ()
forall s. (s -&gt; s) -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#modify"><span class="hs-identifier hs-var">modify</span></a></span><span> </span><span class="annot"><span class="annottext">((CleanS -&gt; CleanS) -&gt; State CleanS ())
-&gt; (CleanS -&gt; CleanS) -&gt; State CleanS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681023809"><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023809"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023809"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sCleanedSpillsAcc :: Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedSpillsAcc"><span class="hs-identifier hs-var">sCleanedSpillsAcc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CleanS -&gt; Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedSpillsAcc"><span class="hs-identifier hs-var hs-var">sCleanedSpillsAcc</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023809"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-359"></span><span>                </span><span class="annot"><span class="annottext">BlockMap IntSet
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
forall instr.
Instruction instr =&gt;
BlockMap IntSet
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBackward"><span class="hs-identifier hs-var">cleanBackward</span></a></span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
</span><a href="#local-6989586621681023816"><span class="hs-identifier hs-var">liveSlotsOnEntry</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Int
</span><a href="#local-6989586621681023814"><span class="hs-identifier hs-var">noReloads</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023813"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023811"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-360"></span><span>
</span><span id="line-361"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#SPILL"><span class="hs-identifier hs-type">SPILL</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681023808"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023808"><span class="hs-identifier hs-var">slot</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
</span><span class="hs-identifier">_</span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023812"><span class="hs-identifier hs-var">li</span></a></span><span>
</span><span id="line-362"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int -&gt; UniqSet Int -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; UniqSet a -&gt; Bool
</span><a href="GHC.Types.Unique.Set.html#elementOfUniqSet"><span class="hs-identifier hs-var">elementOfUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023808"><span class="hs-identifier hs-var">slot</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Int
</span><a href="#local-6989586621681023814"><span class="hs-identifier hs-var">noReloads</span></a></span><span>
</span><span id="line-363"></span><span>
</span><span id="line-364"></span><span>           </span><span class="hs-comment">-- We can erase this spill because the slot won't be read until</span><span>
</span><span id="line-365"></span><span>           </span><span class="hs-comment">-- after the next one</span><span>
</span><span id="line-366"></span><span>           </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-367"></span><span>                </span><span class="annot"><span class="annottext">(CleanS -&gt; CleanS) -&gt; State CleanS ()
forall s. (s -&gt; s) -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#modify"><span class="hs-identifier hs-var">modify</span></a></span><span> </span><span class="annot"><span class="annottext">((CleanS -&gt; CleanS) -&gt; State CleanS ())
-&gt; (CleanS -&gt; CleanS) -&gt; State CleanS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681023806"><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023806"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023806"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sCleanedSpillsAcc :: Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedSpillsAcc"><span class="hs-identifier hs-var">sCleanedSpillsAcc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CleanS -&gt; Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedSpillsAcc"><span class="hs-identifier hs-var hs-var">sCleanedSpillsAcc</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023806"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-368"></span><span>                </span><span class="annot"><span class="annottext">BlockMap IntSet
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
forall instr.
Instruction instr =&gt;
BlockMap IntSet
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBackward"><span class="hs-identifier hs-var">cleanBackward</span></a></span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
</span><a href="#local-6989586621681023816"><span class="hs-identifier hs-var">liveSlotsOnEntry</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Int
</span><a href="#local-6989586621681023814"><span class="hs-identifier hs-var">noReloads</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023813"><span class="hs-identifier hs-var">acc</span></a></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023811"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-369"></span><span>
</span><span id="line-370"></span><span>           </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-371"></span><span>                </span><span class="hs-comment">-- This slot is being spilled to, but we haven't seen any reloads yet.</span><span>
</span><span id="line-372"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681023804"><span class="annot"><span class="annottext">noReloads' :: UniqSet Int
</span><a href="#local-6989586621681023804"><span class="hs-identifier hs-var hs-var">noReloads'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqSet Int -&gt; Int -&gt; UniqSet Int
forall a. Uniquable a =&gt; UniqSet a -&gt; a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#addOneToUniqSet"><span class="hs-identifier hs-var">addOneToUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Int
</span><a href="#local-6989586621681023814"><span class="hs-identifier hs-var">noReloads</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023808"><span class="hs-identifier hs-var">slot</span></a></span><span>
</span><span id="line-373"></span><span>                </span><span class="annot"><span class="annottext">BlockMap IntSet
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
forall instr.
Instruction instr =&gt;
BlockMap IntSet
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBackward"><span class="hs-identifier hs-var">cleanBackward</span></a></span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
</span><a href="#local-6989586621681023816"><span class="hs-identifier hs-var">liveSlotsOnEntry</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Int
</span><a href="#local-6989586621681023804"><span class="hs-identifier hs-var">noReloads'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023812"><span class="hs-identifier hs-var">li</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInstr instr -&gt; [LiveInstr instr] -&gt; [LiveInstr instr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023813"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023811"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-374"></span><span>
</span><span id="line-375"></span><span>        </span><span class="hs-comment">-- if we reload from a slot then it's no longer unused</span><span>
</span><span id="line-376"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#RELOAD"><span class="hs-identifier hs-type">RELOAD</span></a></span><span> </span><span id="local-6989586621681023802"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023802"><span class="hs-identifier hs-var">slot</span></a></span></span><span> </span><span class="annot"><span class="annottext">Reg
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023812"><span class="hs-identifier hs-var">li</span></a></span><span>
</span><span id="line-377"></span><span>        </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681023801"><span class="annot"><span class="annottext">UniqSet Int
</span><a href="#local-6989586621681023801"><span class="hs-identifier hs-var">noReloads'</span></a></span></span><span>            </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UniqSet Int -&gt; Int -&gt; UniqSet Int
forall a. Uniquable a =&gt; UniqSet a -&gt; a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#delOneFromUniqSet"><span class="hs-identifier hs-var">delOneFromUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Int
</span><a href="#local-6989586621681023814"><span class="hs-identifier hs-var">noReloads</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023802"><span class="hs-identifier hs-var">slot</span></a></span><span>
</span><span id="line-378"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
forall instr.
Instruction instr =&gt;
BlockMap IntSet
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBackward"><span class="hs-identifier hs-var">cleanBackward</span></a></span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
</span><a href="#local-6989586621681023816"><span class="hs-identifier hs-var">liveSlotsOnEntry</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Int
</span><a href="#local-6989586621681023801"><span class="hs-identifier hs-var">noReloads'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023812"><span class="hs-identifier hs-var">li</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInstr instr -&gt; [LiveInstr instr] -&gt; [LiveInstr instr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023813"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023811"><span class="hs-identifier hs-var">instrs</span></a></span><span>
</span><span id="line-379"></span><span>
</span><span id="line-380"></span><span>        </span><span class="hs-comment">-- If a slot is live in a jump target then assume it's reloaded there.</span><span>
</span><span id="line-381"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-382"></span><span>        </span><span class="hs-comment">-- TODO: A real dataflow analysis would do a better job here.</span><span>
</span><span id="line-383"></span><span>        </span><span class="hs-comment">--       If the target block _ever_ used the slot then we assume</span><span>
</span><span id="line-384"></span><span>        </span><span class="hs-comment">--       it always does, but if those reloads are cleaned the slot</span><span>
</span><span id="line-385"></span><span>        </span><span class="hs-comment">--       liveness map doesn't get updated.</span><span>
</span><span id="line-386"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Liveness.html#LiveInstr"><span class="hs-identifier hs-type">LiveInstr</span></a></span><span> </span><span id="local-6989586621681023799"><span class="annot"><span class="annottext">InstrSR instr
</span><a href="#local-6989586621681023799"><span class="hs-identifier hs-var">instr</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Liveness
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023812"><span class="hs-identifier hs-var">li</span></a></span><span>
</span><span id="line-387"></span><span>        </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681023798"><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681023798"><span class="hs-identifier hs-var">targets</span></a></span></span><span>               </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">InstrSR instr -&gt; [BlockId]
forall instr. Instruction instr =&gt; instr -&gt; [BlockId]
</span><a href="GHC.CmmToAsm.Instr.html#jumpDestsOfInstr"><span class="hs-identifier hs-var">jumpDestsOfInstr</span></a></span><span> </span><span class="annot"><span class="annottext">InstrSR instr
</span><a href="#local-6989586621681023799"><span class="hs-identifier hs-var">instr</span></a></span><span>
</span><span id="line-388"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-389"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681023794"><span class="annot"><span class="annottext">slotsReloadedByTargets :: IntSet
</span><a href="#local-6989586621681023794"><span class="hs-identifier hs-var hs-var">slotsReloadedByTargets</span></a></span></span><span>
</span><span id="line-390"></span><span>                        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[IntSet] -&gt; IntSet
forall (f :: * -&gt; *). Foldable f =&gt; f IntSet -&gt; IntSet
</span><a href="../../containers/src/Data.IntSet.Internal.html#unions"><span class="hs-identifier hs-var">IntSet.unions</span></a></span><span>
</span><span id="line-391"></span><span>                        </span><span class="annot"><span class="annottext">([IntSet] -&gt; IntSet) -&gt; [IntSet] -&gt; IntSet
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe IntSet] -&gt; [IntSet]
forall a. [Maybe a] -&gt; [a]
</span><a href="../../base/src/Data.Maybe.html#catMaybes"><span class="hs-identifier hs-var">catMaybes</span></a></span><span>
</span><span id="line-392"></span><span>                        </span><span class="annot"><span class="annottext">([Maybe IntSet] -&gt; [IntSet]) -&gt; [Maybe IntSet] -&gt; [IntSet]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(BlockId -&gt; Maybe IntSet) -&gt; [BlockId] -&gt; [Maybe IntSet]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(BlockId -&gt; BlockMap IntSet -&gt; Maybe IntSet)
-&gt; BlockMap IntSet -&gt; BlockId -&gt; Maybe IntSet
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="annot"><span class="annottext">BlockId -&gt; BlockMap IntSet -&gt; Maybe IntSet
forall (map :: * -&gt; *) a.
IsMap map =&gt;
KeyOf map -&gt; map a -&gt; Maybe a
</span><a href="GHC.Cmm.Dataflow.Collections.html#mapLookup"><span class="hs-identifier hs-var">mapLookup</span></a></span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
</span><a href="#local-6989586621681023816"><span class="hs-identifier hs-var">liveSlotsOnEntry</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-393"></span><span>                        </span><span class="annot"><span class="annottext">([BlockId] -&gt; [Maybe IntSet]) -&gt; [BlockId] -&gt; [Maybe IntSet]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId]
</span><a href="#local-6989586621681023798"><span class="hs-identifier hs-var">targets</span></a></span><span>
</span><span id="line-394"></span><span>
</span><span id="line-395"></span><span>                </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681023787"><span class="annot"><span class="annottext">noReloads' :: UniqSet Int
</span><a href="#local-6989586621681023787"><span class="hs-identifier hs-var hs-var">noReloads'</span></a></span></span><span>
</span><span id="line-396"></span><span>                        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UniqSet Int -&gt; Int -&gt; UniqSet Int)
-&gt; UniqSet Int -&gt; [Int] -&gt; UniqSet Int
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Int -&gt; Int -&gt; UniqSet Int
forall a. Uniquable a =&gt; UniqSet a -&gt; a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#delOneFromUniqSet"><span class="hs-identifier hs-var">delOneFromUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Int
</span><a href="#local-6989586621681023814"><span class="hs-identifier hs-var">noReloads</span></a></span><span>
</span><span id="line-397"></span><span>                        </span><span class="annot"><span class="annottext">([Int] -&gt; UniqSet Int) -&gt; [Int] -&gt; UniqSet Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">IntSet -&gt; [Int]
</span><a href="../../containers/src/Data.IntSet.Internal.html#toList"><span class="hs-identifier hs-var">IntSet.toList</span></a></span><span> </span><span class="annot"><span class="annottext">IntSet
</span><a href="#local-6989586621681023794"><span class="hs-identifier hs-var">slotsReloadedByTargets</span></a></span><span>
</span><span id="line-398"></span><span>
</span><span id="line-399"></span><span>                </span><span class="annot"><span class="annottext">BlockMap IntSet
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; State CleanS [LiveInstr instr]
forall instr.
Instruction instr =&gt;
BlockMap IntSet
-&gt; UniqSet Int
-&gt; [LiveInstr instr]
-&gt; [LiveInstr instr]
-&gt; CleanM [LiveInstr instr]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#cleanBackward"><span class="hs-identifier hs-var">cleanBackward</span></a></span><span> </span><span class="annot"><span class="annottext">BlockMap IntSet
</span><a href="#local-6989586621681023816"><span class="hs-identifier hs-var">liveSlotsOnEntry</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Int
</span><a href="#local-6989586621681023787"><span class="hs-identifier hs-var">noReloads'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LiveInstr instr
</span><a href="#local-6989586621681023812"><span class="hs-identifier hs-var">li</span></a></span><span> </span><span class="annot"><span class="annottext">LiveInstr instr -&gt; [LiveInstr instr] -&gt; [LiveInstr instr]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023813"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LiveInstr instr]
</span><a href="#local-6989586621681023811"><span class="hs-identifier hs-var">instrs</span></a></span><span class="hs-cpp">

#if __GLASGOW_HASKELL__ &lt;= 810
</span><span>        </span><span class="hs-comment">-- some other instruction</span><span>
</span><span id="line-403"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">otherwise</span><span>
</span><span id="line-404"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">cleanBackward</span><span> </span><span class="hs-identifier">liveSlotsOnEntry</span><span> </span><span class="hs-identifier">noReloads</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">li</span><span> </span><span class="hs-glyph">:</span><span> </span><span class="hs-identifier">acc</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">instrs</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-407"></span><span>
</span><span id="line-408"></span><span class="hs-comment">-- | Combine the associations from all the inward control flow edges.</span><span>
</span><span id="line-409"></span><span class="hs-comment">--</span><span>
</span><span id="line-410"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#collateJoinPoints"><span class="hs-identifier hs-type">collateJoinPoints</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanM"><span class="hs-identifier hs-type">CleanM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-411"></span><span id="collateJoinPoints"><span class="annot"><span class="annottext">collateJoinPoints :: State CleanS ()
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#collateJoinPoints"><span class="hs-identifier hs-var hs-var">collateJoinPoints</span></a></span></span><span>
</span><span id="line-412"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CleanS -&gt; CleanS) -&gt; State CleanS ()
forall s. (s -&gt; s) -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#modify"><span class="hs-identifier hs-var">modify</span></a></span><span> </span><span class="annot"><span class="annottext">((CleanS -&gt; CleanS) -&gt; State CleanS ())
-&gt; (CleanS -&gt; CleanS) -&gt; State CleanS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681023784"><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023784"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023784"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-413"></span><span>        </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sJumpValid :: UniqFM BlockId (Assoc Store)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sJumpValid"><span class="hs-identifier hs-var">sJumpValid</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Assoc Store] -&gt; Assoc Store)
-&gt; UniqFM BlockId [Assoc Store] -&gt; UniqFM BlockId (Assoc Store)
forall elt1 elt2 key.
(elt1 -&gt; elt2) -&gt; UniqFM key elt1 -&gt; UniqFM key elt2
</span><a href="GHC.Types.Unique.FM.html#mapUFM"><span class="hs-identifier hs-var">mapUFM</span></a></span><span> </span><span class="annot"><span class="annottext">[Assoc Store] -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#intersects"><span class="hs-identifier hs-var">intersects</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CleanS -&gt; UniqFM BlockId [Assoc Store]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sJumpValidAcc"><span class="hs-identifier hs-var hs-var">sJumpValidAcc</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023784"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-414"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sJumpValidAcc :: UniqFM BlockId [Assoc Store]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sJumpValidAcc"><span class="hs-identifier hs-var">sJumpValidAcc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId [Assoc Store]
forall key elt. UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#emptyUFM"><span class="hs-identifier hs-var">emptyUFM</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-415"></span><span>
</span><span id="line-416"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#intersects"><span class="hs-identifier hs-type">intersects</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span>
</span><span id="line-417"></span><span id="intersects"><span class="annot"><span class="annottext">intersects :: [Assoc Store] -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#intersects"><span class="hs-identifier hs-var hs-var">intersects</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Assoc Store
forall a. Assoc a
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#emptyAssoc"><span class="hs-identifier hs-var">emptyAssoc</span></a></span><span>
</span><span id="line-418"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#intersects"><span class="hs-identifier hs-var">intersects</span></a></span><span> </span><span id="local-6989586621681023780"><span class="annot"><span class="annottext">[Assoc Store]
</span><a href="#local-6989586621681023780"><span class="hs-identifier hs-var">assocs</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Assoc Store -&gt; Assoc Store -&gt; Assoc Store)
-&gt; [Assoc Store] -&gt; Assoc Store
forall a. (a -&gt; a -&gt; a) -&gt; [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#foldl1%27"><span class="hs-identifier hs-var">foldl1'</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#intersectAssoc"><span class="hs-identifier hs-var">intersectAssoc</span></a></span><span> </span><span class="annot"><span class="annottext">[Assoc Store]
</span><a href="#local-6989586621681023780"><span class="hs-identifier hs-var">assocs</span></a></span><span>
</span><span id="line-419"></span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span class="hs-comment">-- | See if we have a reg with the same value as this slot in the association table.</span><span>
</span><span id="line-422"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#findRegOfSlot"><span class="hs-identifier hs-type">findRegOfSlot</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span>
</span><span id="line-423"></span><span id="findRegOfSlot"><span class="annot"><span class="annottext">findRegOfSlot :: Assoc Store -&gt; Int -&gt; Maybe Reg
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#findRegOfSlot"><span class="hs-identifier hs-var hs-var">findRegOfSlot</span></a></span></span><span> </span><span id="local-6989586621681023777"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023777"><span class="hs-identifier hs-var">assoc</span></a></span></span><span> </span><span id="local-6989586621681023776"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023776"><span class="hs-identifier hs-var">slot</span></a></span></span><span>
</span><span id="line-424"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681023775"><span class="annot"><span class="annottext">UniqSet Store
</span><a href="#local-6989586621681023775"><span class="hs-identifier hs-var">close</span></a></span></span><span>                 </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Store -&gt; Assoc Store -&gt; UniqSet Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#closeAssoc"><span class="hs-identifier hs-var">closeAssoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SSlot"><span class="hs-identifier hs-var">SSlot</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023776"><span class="hs-identifier hs-var">slot</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023777"><span class="hs-identifier hs-var">assoc</span></a></span><span>
</span><span id="line-425"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-type">SReg</span></a></span><span> </span><span id="local-6989586621681023773"><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023773"><span class="hs-identifier hs-var">reg</span></a></span></span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Store -&gt; Bool) -&gt; [Store] -&gt; Maybe Store
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Maybe a
</span><a href="../../base/src/Data.Foldable.html#find"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="annot"><span class="annottext">Store -&gt; Bool
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#isStoreReg"><span class="hs-identifier hs-var">isStoreReg</span></a></span><span> </span><span class="annot"><span class="annottext">([Store] -&gt; Maybe Store) -&gt; [Store] -&gt; Maybe Store
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Store -&gt; [Store]
forall elt. UniqSet elt -&gt; [elt]
</span><a href="GHC.Types.Unique.Set.html#nonDetEltsUniqSet"><span class="hs-identifier hs-var">nonDetEltsUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Store
</span><a href="#local-6989586621681023775"><span class="hs-identifier hs-var">close</span></a></span><span>
</span><span id="line-426"></span><span>           </span><span class="hs-comment">-- See Note [Unique Determinism and code generation]</span><span>
</span><span id="line-427"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Reg -&gt; Maybe Reg
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023773"><span class="hs-identifier hs-var">reg</span></a></span><span>
</span><span id="line-428"></span><span>
</span><span id="line-429"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-430"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Reg
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-431"></span><span>
</span><span id="line-432"></span><span>
</span><span id="line-433"></span><span class="hs-comment">-------------------------------------------------------------------------------</span><span>
</span><span id="line-434"></span><span class="hs-comment">-- | Cleaner monad.</span><span>
</span><span id="line-435"></span><span class="hs-keyword">type</span><span> </span><span id="CleanM"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanM"><span class="hs-identifier hs-var">CleanM</span></a></span></span><span>
</span><span id="line-436"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Utils.Monad.State.html#State"><span class="hs-identifier hs-type">State</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanS"><span class="hs-identifier hs-type">CleanS</span></a></span><span>
</span><span id="line-437"></span><span>
</span><span id="line-438"></span><span class="hs-comment">-- | Cleaner state.</span><span>
</span><span id="line-439"></span><span class="hs-keyword">data</span><span> </span><span id="CleanS"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanS"><span class="hs-identifier hs-var">CleanS</span></a></span></span><span>
</span><span id="line-440"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span id="CleanS"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanS"><span class="hs-identifier hs-var">CleanS</span></a></span></span><span>
</span><span id="line-441"></span><span>        </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- | Regs which are valid at the start of each block.</span><span>
</span><span id="line-442"></span><span>          </span><span id="sJumpValid"><span class="annot"><span class="annottext">CleanS -&gt; UniqFM BlockId (Assoc Store)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sJumpValid"><span class="hs-identifier hs-var hs-var">sJumpValid</span></a></span></span><span>            </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html#UniqFM"><span class="hs-identifier hs-type">UniqFM</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-443"></span><span>
</span><span id="line-444"></span><span>          </span><span class="hs-comment">-- | Collecting up what regs were valid across each jump.</span><span>
</span><span id="line-445"></span><span>          </span><span class="hs-comment">--    in the next pass we can collate these and write the results</span><span>
</span><span id="line-446"></span><span>          </span><span class="hs-comment">--    to sJumpValid.</span><span>
</span><span id="line-447"></span><span>        </span><span class="hs-special">,</span><span> </span><span id="sJumpValidAcc"><span class="annot"><span class="annottext">CleanS -&gt; UniqFM BlockId [Assoc Store]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sJumpValidAcc"><span class="hs-identifier hs-var hs-var">sJumpValidAcc</span></a></span></span><span>         </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html#UniqFM"><span class="hs-identifier hs-type">UniqFM</span></a></span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-448"></span><span>
</span><span id="line-449"></span><span>          </span><span class="hs-comment">-- | Map of (slot -&gt; blocks which reload from this slot)</span><span>
</span><span id="line-450"></span><span>          </span><span class="hs-comment">--    used to decide if whether slot spilled to will ever be</span><span>
</span><span id="line-451"></span><span>          </span><span class="hs-comment">--    reloaded from on this path.</span><span>
</span><span id="line-452"></span><span>        </span><span class="hs-special">,</span><span> </span><span id="sReloadedBy"><span class="annot"><span class="annottext">CleanS -&gt; UniqFM Store [BlockId]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sReloadedBy"><span class="hs-identifier hs-var hs-var">sReloadedBy</span></a></span></span><span>           </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html#UniqFM"><span class="hs-identifier hs-type">UniqFM</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-453"></span><span>
</span><span id="line-454"></span><span>          </span><span class="hs-comment">-- | Spills and reloads cleaned each pass (latest at front)</span><span>
</span><span id="line-455"></span><span>        </span><span class="hs-special">,</span><span> </span><span id="sCleanedCount"><span class="annot"><span class="annottext">CleanS -&gt; [(Int, Int)]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedCount"><span class="hs-identifier hs-var hs-var">sCleanedCount</span></a></span></span><span>         </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-456"></span><span>
</span><span id="line-457"></span><span>          </span><span class="hs-comment">-- | Spills and reloads that have been cleaned in this pass so far.</span><span>
</span><span id="line-458"></span><span>        </span><span class="hs-special">,</span><span> </span><span id="sCleanedSpillsAcc"><span class="annot"><span class="annottext">CleanS -&gt; Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedSpillsAcc"><span class="hs-identifier hs-var hs-var">sCleanedSpillsAcc</span></a></span></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-459"></span><span>        </span><span class="hs-special">,</span><span> </span><span id="sCleanedReloadsAcc"><span class="annot"><span class="annottext">CleanS -&gt; Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedReloadsAcc"><span class="hs-identifier hs-var hs-var">sCleanedReloadsAcc</span></a></span></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-460"></span><span>
</span><span id="line-461"></span><span>
</span><span id="line-462"></span><span class="hs-comment">-- | Construct the initial cleaner state.</span><span>
</span><span id="line-463"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#initCleanS"><span class="hs-identifier hs-type">initCleanS</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanS"><span class="hs-identifier hs-type">CleanS</span></a></span><span>
</span><span id="line-464"></span><span id="initCleanS"><span class="annot"><span class="annottext">initCleanS :: CleanS
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#initCleanS"><span class="hs-identifier hs-var hs-var">initCleanS</span></a></span></span><span>
</span><span id="line-465"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CleanS :: UniqFM BlockId (Assoc Store)
-&gt; UniqFM BlockId [Assoc Store]
-&gt; UniqFM Store [BlockId]
-&gt; [(Int, Int)]
-&gt; Int
-&gt; Int
-&gt; CleanS
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanS"><span class="hs-identifier hs-type">CleanS</span></a></span><span>
</span><span id="line-466"></span><span>        </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sJumpValid :: UniqFM BlockId (Assoc Store)
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sJumpValid"><span class="hs-identifier hs-var">sJumpValid</span></a></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId (Assoc Store)
forall key elt. UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#emptyUFM"><span class="hs-identifier hs-var">emptyUFM</span></a></span><span>
</span><span id="line-467"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sJumpValidAcc :: UniqFM BlockId [Assoc Store]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sJumpValidAcc"><span class="hs-identifier hs-var">sJumpValidAcc</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM BlockId [Assoc Store]
forall key elt. UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#emptyUFM"><span class="hs-identifier hs-var">emptyUFM</span></a></span><span>
</span><span id="line-468"></span><span>
</span><span id="line-469"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sReloadedBy :: UniqFM Store [BlockId]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sReloadedBy"><span class="hs-identifier hs-var">sReloadedBy</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM Store [BlockId]
forall key elt. UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#emptyUFM"><span class="hs-identifier hs-var">emptyUFM</span></a></span><span>
</span><span id="line-470"></span><span>
</span><span id="line-471"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sCleanedCount :: [(Int, Int)]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedCount"><span class="hs-identifier hs-var">sCleanedCount</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-472"></span><span>
</span><span id="line-473"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sCleanedSpillsAcc :: Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedSpillsAcc"><span class="hs-identifier hs-var">sCleanedSpillsAcc</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-474"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sCleanedReloadsAcc :: Int
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sCleanedReloadsAcc"><span class="hs-identifier hs-var">sCleanedReloadsAcc</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-475"></span><span>
</span><span id="line-476"></span><span>
</span><span id="line-477"></span><span class="hs-comment">-- | Remember the associations before a jump.</span><span>
</span><span id="line-478"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#accJumpValid"><span class="hs-identifier hs-type">accJumpValid</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanM"><span class="hs-identifier hs-type">CleanM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-479"></span><span id="accJumpValid"><span class="annot"><span class="annottext">accJumpValid :: Assoc Store -&gt; BlockId -&gt; State CleanS ()
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#accJumpValid"><span class="hs-identifier hs-var hs-var">accJumpValid</span></a></span></span><span> </span><span id="local-6989586621681023768"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023768"><span class="hs-identifier hs-var">assocs</span></a></span></span><span> </span><span id="local-6989586621681023767"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023767"><span class="hs-identifier hs-var">target</span></a></span></span><span>
</span><span id="line-480"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CleanS -&gt; CleanS) -&gt; State CleanS ()
forall s. (s -&gt; s) -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#modify"><span class="hs-identifier hs-var">modify</span></a></span><span> </span><span class="annot"><span class="annottext">((CleanS -&gt; CleanS) -&gt; State CleanS ())
-&gt; (CleanS -&gt; CleanS) -&gt; State CleanS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681023766"><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023766"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023766"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-481"></span><span>        </span><span class="annot"><span class="annottext">sJumpValidAcc :: UniqFM BlockId [Assoc Store]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sJumpValidAcc"><span class="hs-identifier hs-var">sJumpValidAcc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Assoc Store] -&gt; [Assoc Store] -&gt; [Assoc Store])
-&gt; UniqFM BlockId [Assoc Store]
-&gt; BlockId
-&gt; [Assoc Store]
-&gt; UniqFM BlockId [Assoc Store]
forall key elt.
Uniquable key =&gt;
(elt -&gt; elt -&gt; elt)
-&gt; UniqFM key elt -&gt; key -&gt; elt -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#addToUFM_C"><span class="hs-identifier hs-var">addToUFM_C</span></a></span><span> </span><span class="annot"><span class="annottext">[Assoc Store] -&gt; [Assoc Store] -&gt; [Assoc Store]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">(++)</span></a></span><span>
</span><span id="line-482"></span><span>                                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CleanS -&gt; UniqFM BlockId [Assoc Store]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sJumpValidAcc"><span class="hs-identifier hs-var hs-var">sJumpValidAcc</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023766"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-483"></span><span>                                </span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023767"><span class="hs-identifier hs-var">target</span></a></span><span>
</span><span id="line-484"></span><span>                                </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023768"><span class="hs-identifier hs-var">assocs</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-485"></span><span>
</span><span id="line-486"></span><span>
</span><span id="line-487"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#accBlockReloadsSlot"><span class="hs-identifier hs-type">accBlockReloadsSlot</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Cmm.BlockId.html#BlockId"><span class="hs-identifier hs-type">BlockId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Slot"><span class="hs-identifier hs-type">Slot</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#CleanM"><span class="hs-identifier hs-type">CleanM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-488"></span><span id="accBlockReloadsSlot"><span class="annot"><span class="annottext">accBlockReloadsSlot :: BlockId -&gt; Int -&gt; State CleanS ()
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#accBlockReloadsSlot"><span class="hs-identifier hs-var hs-var">accBlockReloadsSlot</span></a></span></span><span> </span><span id="local-6989586621681023764"><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023764"><span class="hs-identifier hs-var">blockId</span></a></span></span><span> </span><span id="local-6989586621681023763"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023763"><span class="hs-identifier hs-var">slot</span></a></span></span><span>
</span><span id="line-489"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CleanS -&gt; CleanS) -&gt; State CleanS ()
forall s. (s -&gt; s) -&gt; State s ()
</span><a href="GHC.Utils.Monad.State.html#modify"><span class="hs-identifier hs-var">modify</span></a></span><span> </span><span class="annot"><span class="annottext">((CleanS -&gt; CleanS) -&gt; State CleanS ())
-&gt; (CleanS -&gt; CleanS) -&gt; State CleanS ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681023762"><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023762"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023762"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-490"></span><span>        </span><span class="annot"><span class="annottext">sReloadedBy :: UniqFM Store [BlockId]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sReloadedBy"><span class="hs-identifier hs-var">sReloadedBy</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([BlockId] -&gt; [BlockId] -&gt; [BlockId])
-&gt; UniqFM Store [BlockId]
-&gt; Store
-&gt; [BlockId]
-&gt; UniqFM Store [BlockId]
forall key elt.
Uniquable key =&gt;
(elt -&gt; elt -&gt; elt)
-&gt; UniqFM key elt -&gt; key -&gt; elt -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#addToUFM_C"><span class="hs-identifier hs-var">addToUFM_C</span></a></span><span> </span><span class="annot"><span class="annottext">[BlockId] -&gt; [BlockId] -&gt; [BlockId]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">(++)</span></a></span><span>
</span><span id="line-491"></span><span>                                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CleanS -&gt; UniqFM Store [BlockId]
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#sReloadedBy"><span class="hs-identifier hs-var hs-var">sReloadedBy</span></a></span><span> </span><span class="annot"><span class="annottext">CleanS
</span><a href="#local-6989586621681023762"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-492"></span><span>                                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SSlot"><span class="hs-identifier hs-var">SSlot</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023763"><span class="hs-identifier hs-var">slot</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-493"></span><span>                                </span><span class="hs-special">[</span><span class="annot"><span class="annottext">BlockId
</span><a href="#local-6989586621681023764"><span class="hs-identifier hs-var">blockId</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-494"></span><span>
</span><span id="line-495"></span><span>
</span><span id="line-496"></span><span class="hs-comment">-------------------------------------------------------------------------------</span><span>
</span><span id="line-497"></span><span class="hs-comment">-- A store location can be a stack slot or a register</span><span>
</span><span id="line-498"></span><span class="hs-keyword">data</span><span> </span><span id="Store"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-var">Store</span></a></span></span><span>
</span><span id="line-499"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span id="SSlot"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SSlot"><span class="hs-identifier hs-var">SSlot</span></a></span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-500"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span id="SReg"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-var">SReg</span></a></span></span><span>  </span><span class="annot"><a href="GHC.Platform.Reg.html#Reg"><span class="hs-identifier hs-type">Reg</span></a></span><span>
</span><span id="line-501"></span><span>
</span><span id="line-502"></span><span>
</span><span id="line-503"></span><span class="hs-comment">-- | Check if this is a reg store.</span><span>
</span><span id="line-504"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#isStoreReg"><span class="hs-identifier hs-type">isStoreReg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-505"></span><span id="isStoreReg"><span class="annot"><span class="annottext">isStoreReg :: Store -&gt; Bool
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#isStoreReg"><span class="hs-identifier hs-var hs-var">isStoreReg</span></a></span></span><span> </span><span id="local-6989586621681023761"><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023761"><span class="hs-identifier hs-var">ss</span></a></span></span><span>
</span><span id="line-506"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023761"><span class="hs-identifier hs-var">ss</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-507"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SSlot"><span class="hs-identifier hs-type">SSlot</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-508"></span><span>        </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-type">SReg</span></a></span><span>  </span><span class="annot"><span class="annottext">Reg
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-509"></span><span>
</span><span id="line-510"></span><span>
</span><span id="line-511"></span><span class="hs-comment">-- Spill cleaning is only done once all virtuals have been allocated to realRegs</span><span>
</span><span id="line-512"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="GHC.Types.Unique.html#Uniquable"><span class="hs-identifier hs-type">Uniquable</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-513"></span><span>    </span><span id="local-6989586621681023753"><span class="annot"><span class="annottext">getUnique :: Store -&gt; Unique
</span><a href="GHC.Types.Unique.html#getUnique"><span class="hs-identifier hs-var hs-var hs-var hs-var">getUnique</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-type">SReg</span></a></span><span>  </span><span id="local-6989586621681023751"><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023751"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-514"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#RegReal"><span class="hs-identifier hs-type">RegReal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Platform.Reg.html#RealRegSingle"><span class="hs-identifier hs-type">RealRegSingle</span></a></span><span> </span><span id="local-6989586621681023748"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023748"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023751"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-515"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Unique
</span><a href="GHC.Types.Unique.html#mkRegSingleUnique"><span class="hs-identifier hs-var">mkRegSingleUnique</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023748"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-516"></span><span>
</span><span id="line-517"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Platform.Reg.html#RegReal"><span class="hs-identifier hs-type">RegReal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Platform.Reg.html#RealRegPair"><span class="hs-identifier hs-type">RealRegPair</span></a></span><span> </span><span id="local-6989586621681023745"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023745"><span class="hs-identifier hs-var">r1</span></a></span></span><span> </span><span id="local-6989586621681023744"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023744"><span class="hs-identifier hs-var">r2</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023751"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-518"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Unique
</span><a href="GHC.Types.Unique.html#mkRegPairUnique"><span class="hs-identifier hs-var">mkRegPairUnique</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023745"><span class="hs-identifier hs-var">r1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">65535</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023744"><span class="hs-identifier hs-var">r2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-519"></span><span>
</span><span id="line-520"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-521"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Unique
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Unique) -&gt; String -&gt; Unique
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;RegSpillClean.getUnique: found virtual reg during spill clean,&quot;</span></span><span>
</span><span id="line-522"></span><span>                </span><span class="annot"><span class="annottext">String -&gt; String -&gt; String
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;only real regs expected.&quot;</span></span><span>
</span><span id="line-523"></span><span>
</span><span id="line-524"></span><span>    </span><span class="annot"><a href="GHC.Types.Unique.html#getUnique"><span class="hs-identifier hs-var">getUnique</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SSlot"><span class="hs-identifier hs-type">SSlot</span></a></span><span> </span><span id="local-6989586621681023740"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023740"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Unique
</span><a href="GHC.Types.Unique.html#mkRegSubUnique"><span class="hs-identifier hs-var">mkRegSubUnique</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023740"><span class="hs-identifier hs-var">i</span></a></span><span>    </span><span class="hs-comment">-- [SLPJ] I hope &quot;SubUnique&quot; is ok</span><span>
</span><span id="line-525"></span><span>
</span><span id="line-526"></span><span>
</span><span id="line-527"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681023736"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-528"></span><span>        </span><span id="local-6989586621681023732"><span class="annot"><span class="annottext">ppr :: Store -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SSlot"><span class="hs-identifier hs-type">SSlot</span></a></span><span> </span><span id="local-6989586621681023730"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023730"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;slot&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#int"><span class="hs-identifier hs-var">int</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681023730"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-529"></span><span>        </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#SReg"><span class="hs-identifier hs-type">SReg</span></a></span><span>  </span><span id="local-6989586621681023726"><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023726"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Reg -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Reg
</span><a href="#local-6989586621681023726"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-530"></span><span>
</span><span id="line-531"></span><span>
</span><span id="line-532"></span><span class="hs-comment">-------------------------------------------------------------------------------</span><span>
</span><span id="line-533"></span><span class="hs-comment">-- Association graphs.</span><span>
</span><span id="line-534"></span><span class="hs-comment">-- In the spill cleaner, two store locations are associated if they are known</span><span>
</span><span id="line-535"></span><span class="hs-comment">-- to hold the same value.</span><span>
</span><span id="line-536"></span><span class="hs-comment">--</span><span>
</span><span id="line-537"></span><span class="hs-comment">-- TODO: Monomorphize: I think we only ever use this with a ~ Store</span><span>
</span><span id="line-538"></span><span class="hs-keyword">type</span><span> </span><span id="Assoc"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-var">Assoc</span></a></span></span><span> </span><span id="local-6989586621681023725"><span class="annot"><a href="#local-6989586621681023725"><span class="hs-identifier hs-type">a</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Types.Unique.FM.html#UniqFM"><span class="hs-identifier hs-type">UniqFM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681023725"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Unique.Set.html#UniqSet"><span class="hs-identifier hs-type">UniqSet</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681023725"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-539"></span><span>
</span><span id="line-540"></span><span class="hs-comment">-- | An empty association</span><span>
</span><span id="line-541"></span><span id="local-6989586621681024182"><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#emptyAssoc"><span class="hs-identifier hs-type">emptyAssoc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681024182"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-542"></span><span id="emptyAssoc"><span class="annot"><span class="annottext">emptyAssoc :: forall a. Assoc a
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#emptyAssoc"><span class="hs-identifier hs-var hs-var">emptyAssoc</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UniqFM a (UniqSet a)
forall key elt. UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#emptyUFM"><span class="hs-identifier hs-var">emptyUFM</span></a></span><span>
</span><span id="line-543"></span><span>
</span><span id="line-544"></span><span>
</span><span id="line-545"></span><span class="hs-comment">-- | Add an association between these two things.</span><span>
</span><span id="line-546"></span><span class="hs-comment">-- addAssoc :: Uniquable a</span><span>
</span><span id="line-547"></span><span class="hs-comment">--          =&gt; a -&gt; a -&gt; Assoc a -&gt; Assoc a</span><span>
</span><span id="line-548"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#addAssoc"><span class="hs-identifier hs-type">addAssoc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span>
</span><span id="line-549"></span><span>
</span><span id="line-550"></span><span id="addAssoc"><span class="annot"><span class="annottext">addAssoc :: Store -&gt; Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#addAssoc"><span class="hs-identifier hs-var hs-var">addAssoc</span></a></span></span><span> </span><span id="local-6989586621681023724"><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023724"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621681023723"><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023723"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621681023722"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023722"><span class="hs-identifier hs-var">m</span></a></span></span><span>
</span><span id="line-551"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span>  </span><span id="local-6989586621681023719"><span class="annot"><span class="annottext">m1 :: Assoc Store
</span><a href="#local-6989586621681023719"><span class="hs-identifier hs-var hs-var">m1</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UniqSet Store -&gt; UniqSet Store -&gt; UniqSet Store)
-&gt; Assoc Store -&gt; Store -&gt; UniqSet Store -&gt; Assoc Store
forall key elt.
Uniquable key =&gt;
(elt -&gt; elt -&gt; elt)
-&gt; UniqFM key elt -&gt; key -&gt; elt -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#addToUFM_C"><span class="hs-identifier hs-var">addToUFM_C</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Store -&gt; UniqSet Store -&gt; UniqSet Store
forall a. UniqSet a -&gt; UniqSet a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#unionUniqSets"><span class="hs-identifier hs-var">unionUniqSets</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023722"><span class="hs-identifier hs-var">m</span></a></span><span>  </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023724"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Store -&gt; UniqSet Store
forall a. Uniquable a =&gt; a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#unitUniqSet"><span class="hs-identifier hs-var">unitUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023723"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-552"></span><span>        </span><span id="local-6989586621681023714"><span class="annot"><span class="annottext">m2 :: Assoc Store
</span><a href="#local-6989586621681023714"><span class="hs-identifier hs-var hs-var">m2</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UniqSet Store -&gt; UniqSet Store -&gt; UniqSet Store)
-&gt; Assoc Store -&gt; Store -&gt; UniqSet Store -&gt; Assoc Store
forall key elt.
Uniquable key =&gt;
(elt -&gt; elt -&gt; elt)
-&gt; UniqFM key elt -&gt; key -&gt; elt -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#addToUFM_C"><span class="hs-identifier hs-var">addToUFM_C</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Store -&gt; UniqSet Store -&gt; UniqSet Store
forall a. UniqSet a -&gt; UniqSet a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#unionUniqSets"><span class="hs-identifier hs-var">unionUniqSets</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023719"><span class="hs-identifier hs-var">m1</span></a></span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023723"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Store -&gt; UniqSet Store
forall a. Uniquable a =&gt; a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#unitUniqSet"><span class="hs-identifier hs-var">unitUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023724"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-553"></span><span>   </span><span class="hs-keyword">in</span><span>   </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023714"><span class="hs-identifier hs-var">m2</span></a></span><span>
</span><span id="line-554"></span><span>
</span><span id="line-555"></span><span>
</span><span id="line-556"></span><span class="hs-comment">-- | Delete all associations to a node.</span><span>
</span><span id="line-557"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#delAssoc"><span class="hs-identifier hs-type">delAssoc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span>
</span><span id="line-558"></span><span id="delAssoc"><span class="annot"><span class="annottext">delAssoc :: Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#delAssoc"><span class="hs-identifier hs-var hs-var">delAssoc</span></a></span></span><span> </span><span id="local-6989586621681023713"><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023713"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621681023712"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023712"><span class="hs-identifier hs-var">m</span></a></span></span><span>
</span><span id="line-559"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681023711"><span class="annot"><span class="annottext">UniqSet Store
</span><a href="#local-6989586621681023711"><span class="hs-identifier hs-var">aSet</span></a></span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Assoc Store -&gt; Store -&gt; Maybe (UniqSet Store)
forall key elt. Uniquable key =&gt; UniqFM key elt -&gt; key -&gt; Maybe elt
</span><a href="GHC.Types.Unique.FM.html#lookupUFM"><span class="hs-identifier hs-var">lookupUFM</span></a></span><span>  </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023712"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023713"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-560"></span><span>        </span><span class="hs-special">,</span><span> </span><span id="local-6989586621681023710"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023710"><span class="hs-identifier hs-var">m1</span></a></span></span><span>            </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Assoc Store -&gt; Store -&gt; Assoc Store
forall key elt.
Uniquable key =&gt;
UniqFM key elt -&gt; key -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#delFromUFM"><span class="hs-identifier hs-var">delFromUFM</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023712"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023713"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-561"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Store -&gt; Assoc Store -&gt; Assoc Store)
-&gt; Assoc Store -&gt; UniqSet Store -&gt; Assoc Store
forall elt a. (elt -&gt; a -&gt; a) -&gt; a -&gt; UniqSet elt -&gt; a
</span><a href="GHC.Types.Unique.Set.html#nonDetStrictFoldUniqSet"><span class="hs-identifier hs-var">nonDetStrictFoldUniqSet</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681023707"><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023707"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681023706"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023706"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Store -&gt; Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#delAssoc1"><span class="hs-identifier hs-var">delAssoc1</span></a></span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023707"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023713"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023706"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023710"><span class="hs-identifier hs-var">m1</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Store
</span><a href="#local-6989586621681023711"><span class="hs-identifier hs-var">aSet</span></a></span><span>
</span><span id="line-562"></span><span>          </span><span class="hs-comment">-- It's OK to use a non-deterministic fold here because deletion is</span><span>
</span><span id="line-563"></span><span>          </span><span class="hs-comment">-- commutative</span><span>
</span><span id="line-564"></span><span>
</span><span id="line-565"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023712"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-566"></span><span>
</span><span id="line-567"></span><span>
</span><span id="line-568"></span><span class="hs-comment">-- | Delete a single association edge (a -&gt; b).</span><span>
</span><span id="line-569"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#delAssoc1"><span class="hs-identifier hs-type">delAssoc1</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span>
</span><span id="line-570"></span><span id="delAssoc1"><span class="annot"><span class="annottext">delAssoc1 :: Store -&gt; Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#delAssoc1"><span class="hs-identifier hs-var hs-var">delAssoc1</span></a></span></span><span> </span><span id="local-6989586621681023704"><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023704"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621681023703"><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023703"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621681023702"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023702"><span class="hs-identifier hs-var">m</span></a></span></span><span>
</span><span id="line-571"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681023701"><span class="annot"><span class="annottext">UniqSet Store
</span><a href="#local-6989586621681023701"><span class="hs-identifier hs-var">aSet</span></a></span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Assoc Store -&gt; Store -&gt; Maybe (UniqSet Store)
forall key elt. Uniquable key =&gt; UniqFM key elt -&gt; key -&gt; Maybe elt
</span><a href="GHC.Types.Unique.FM.html#lookupUFM"><span class="hs-identifier hs-var">lookupUFM</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023702"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023704"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-572"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Assoc Store -&gt; Store -&gt; UniqSet Store -&gt; Assoc Store
forall key elt.
Uniquable key =&gt;
UniqFM key elt -&gt; key -&gt; elt -&gt; UniqFM key elt
</span><a href="GHC.Types.Unique.FM.html#addToUFM"><span class="hs-identifier hs-var">addToUFM</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023702"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023704"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UniqSet Store -&gt; Store -&gt; UniqSet Store
forall a. Uniquable a =&gt; UniqSet a -&gt; a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#delOneFromUniqSet"><span class="hs-identifier hs-var">delOneFromUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Store
</span><a href="#local-6989586621681023701"><span class="hs-identifier hs-var">aSet</span></a></span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023703"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-573"></span><span>
</span><span id="line-574"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023702"><span class="hs-identifier hs-var">m</span></a></span><span>
</span><span id="line-575"></span><span>
</span><span id="line-576"></span><span>
</span><span id="line-577"></span><span class="hs-comment">-- | Check if these two things are associated.</span><span>
</span><span id="line-578"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#elemAssoc"><span class="hs-identifier hs-type">elemAssoc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-579"></span><span>
</span><span id="line-580"></span><span id="elemAssoc"><span class="annot"><span class="annottext">elemAssoc :: Store -&gt; Store -&gt; Assoc Store -&gt; Bool
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#elemAssoc"><span class="hs-identifier hs-var hs-var">elemAssoc</span></a></span></span><span> </span><span id="local-6989586621681023699"><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023699"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621681023698"><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023698"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621681023697"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023697"><span class="hs-identifier hs-var">m</span></a></span></span><span>
</span><span id="line-581"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Store -&gt; UniqSet Store -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; UniqSet a -&gt; Bool
</span><a href="GHC.Types.Unique.Set.html#elementOfUniqSet"><span class="hs-identifier hs-var">elementOfUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023698"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Store -&gt; Assoc Store -&gt; UniqSet Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#closeAssoc"><span class="hs-identifier hs-var">closeAssoc</span></a></span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023699"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023697"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-582"></span><span>
</span><span id="line-583"></span><span>
</span><span id="line-584"></span><span class="hs-comment">-- | Find the refl. trans. closure of the association from this point.</span><span>
</span><span id="line-585"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#closeAssoc"><span class="hs-identifier hs-type">closeAssoc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Unique.Set.html#UniqSet"><span class="hs-identifier hs-type">UniqSet</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span>
</span><span id="line-586"></span><span id="closeAssoc"><span class="annot"><span class="annottext">closeAssoc :: Store -&gt; Assoc Store -&gt; UniqSet Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#closeAssoc"><span class="hs-identifier hs-var hs-var">closeAssoc</span></a></span></span><span> </span><span id="local-6989586621681023696"><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023696"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621681023695"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023695"><span class="hs-identifier hs-var">assoc</span></a></span></span><span>
</span><span id="line-587"></span><span> </span><span class="hs-glyph">=</span><span>      </span><span class="annot"><span class="annottext">Assoc Store -&gt; UniqSet Store -&gt; UniqSet Store -&gt; UniqSet Store
forall {a}.
Uniquable a =&gt;
UniqFM a (UniqSet a) -&gt; UniqSet a -&gt; UniqSet a -&gt; UniqSet a
</span><a href="#local-6989586621681023694"><span class="hs-identifier hs-var">closeAssoc'</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023695"><span class="hs-identifier hs-var">assoc</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet Store
forall a. UniqSet a
</span><a href="GHC.Types.Unique.Set.html#emptyUniqSet"><span class="hs-identifier hs-var">emptyUniqSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Store -&gt; UniqSet Store
forall a. Uniquable a =&gt; a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#unitUniqSet"><span class="hs-identifier hs-var">unitUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">Store
</span><a href="#local-6989586621681023696"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-588"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-589"></span><span>        </span><span id="local-6989586621681023694"><span class="annot"><span class="annottext">closeAssoc' :: UniqFM a (UniqSet a) -&gt; UniqSet a -&gt; UniqSet a -&gt; UniqSet a
</span><a href="#local-6989586621681023694"><span class="hs-identifier hs-var hs-var">closeAssoc'</span></a></span></span><span> </span><span id="local-6989586621681023689"><span class="annot"><span class="annottext">UniqFM a (UniqSet a)
</span><a href="#local-6989586621681023689"><span class="hs-identifier hs-var">assoc</span></a></span></span><span> </span><span id="local-6989586621681023688"><span class="annot"><span class="annottext">UniqSet a
</span><a href="#local-6989586621681023688"><span class="hs-identifier hs-var">visited</span></a></span></span><span> </span><span id="local-6989586621681023687"><span class="annot"><span class="annottext">UniqSet a
</span><a href="#local-6989586621681023687"><span class="hs-identifier hs-var">toVisit</span></a></span></span><span>
</span><span id="line-590"></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">UniqSet a -&gt; [a]
forall elt. UniqSet elt -&gt; [elt]
</span><a href="GHC.Types.Unique.Set.html#nonDetEltsUniqSet"><span class="hs-identifier hs-var">nonDetEltsUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet a
</span><a href="#local-6989586621681023687"><span class="hs-identifier hs-var">toVisit</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-591"></span><span>             </span><span class="hs-comment">-- See Note [Unique Determinism and code generation]</span><span>
</span><span id="line-592"></span><span>
</span><span id="line-593"></span><span>                </span><span class="hs-comment">-- nothing else to visit, we're done</span><span>
</span><span id="line-594"></span><span>                </span><span class="hs-special">[</span><span class="hs-special">]</span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UniqSet a
</span><a href="#local-6989586621681023688"><span class="hs-identifier hs-var">visited</span></a></span><span>
</span><span id="line-595"></span><span>
</span><span id="line-596"></span><span>                </span><span class="hs-special">(</span><span id="local-6989586621681023686"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681023686"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[a]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-597"></span><span>                 </span><span class="hs-comment">-- we've already seen this node</span><span>
</span><span id="line-598"></span><span>                 </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">a -&gt; UniqSet a -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; UniqSet a -&gt; Bool
</span><a href="GHC.Types.Unique.Set.html#elementOfUniqSet"><span class="hs-identifier hs-var">elementOfUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681023686"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet a
</span><a href="#local-6989586621681023688"><span class="hs-identifier hs-var">visited</span></a></span><span>
</span><span id="line-599"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UniqFM a (UniqSet a) -&gt; UniqSet a -&gt; UniqSet a -&gt; UniqSet a
</span><a href="#local-6989586621681023694"><span class="hs-identifier hs-var">closeAssoc'</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM a (UniqSet a)
</span><a href="#local-6989586621681023689"><span class="hs-identifier hs-var">assoc</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet a
</span><a href="#local-6989586621681023688"><span class="hs-identifier hs-var">visited</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UniqSet a -&gt; a -&gt; UniqSet a
forall a. Uniquable a =&gt; UniqSet a -&gt; a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#delOneFromUniqSet"><span class="hs-identifier hs-var">delOneFromUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet a
</span><a href="#local-6989586621681023687"><span class="hs-identifier hs-var">toVisit</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681023686"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-600"></span><span>
</span><span id="line-601"></span><span>                 </span><span class="hs-comment">-- haven't seen this node before,</span><span>
</span><span id="line-602"></span><span>                 </span><span class="hs-comment">--     remember to visit all its neighbors</span><span>
</span><span id="line-603"></span><span>                 </span><span class="hs-glyph">|</span><span>  </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-604"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681023684"><span class="annot"><span class="annottext">neighbors :: UniqSet a
</span><a href="#local-6989586621681023684"><span class="hs-identifier hs-var hs-var">neighbors</span></a></span></span><span>
</span><span id="line-605"></span><span>                         </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">UniqFM a (UniqSet a) -&gt; a -&gt; Maybe (UniqSet a)
forall key elt. Uniquable key =&gt; UniqFM key elt -&gt; key -&gt; Maybe elt
</span><a href="GHC.Types.Unique.FM.html#lookupUFM"><span class="hs-identifier hs-var">lookupUFM</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM a (UniqSet a)
</span><a href="#local-6989586621681023689"><span class="hs-identifier hs-var">assoc</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681023686"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-606"></span><span>                                </span><span class="annot"><span class="annottext">Maybe (UniqSet a)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UniqSet a
forall a. UniqSet a
</span><a href="GHC.Types.Unique.Set.html#emptyUniqSet"><span class="hs-identifier hs-var">emptyUniqSet</span></a></span><span>
</span><span id="line-607"></span><span>                                </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681023683"><span class="annot"><span class="annottext">UniqSet a
</span><a href="#local-6989586621681023683"><span class="hs-identifier hs-var">set</span></a></span></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">UniqSet a
</span><a href="#local-6989586621681023683"><span class="hs-identifier hs-var">set</span></a></span><span>
</span><span id="line-608"></span><span>
</span><span id="line-609"></span><span>                   </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">UniqFM a (UniqSet a) -&gt; UniqSet a -&gt; UniqSet a -&gt; UniqSet a
</span><a href="#local-6989586621681023694"><span class="hs-identifier hs-var">closeAssoc'</span></a></span><span> </span><span class="annot"><span class="annottext">UniqFM a (UniqSet a)
</span><a href="#local-6989586621681023689"><span class="hs-identifier hs-var">assoc</span></a></span><span>
</span><span id="line-610"></span><span>                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UniqSet a -&gt; a -&gt; UniqSet a
forall a. Uniquable a =&gt; UniqSet a -&gt; a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#addOneToUniqSet"><span class="hs-identifier hs-var">addOneToUniqSet</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet a
</span><a href="#local-6989586621681023688"><span class="hs-identifier hs-var">visited</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681023686"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-611"></span><span>                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UniqSet a -&gt; UniqSet a -&gt; UniqSet a
forall a. UniqSet a -&gt; UniqSet a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#unionUniqSets"><span class="hs-identifier hs-var">unionUniqSets</span></a></span><span>   </span><span class="annot"><span class="annottext">UniqSet a
</span><a href="#local-6989586621681023687"><span class="hs-identifier hs-var">toVisit</span></a></span><span> </span><span class="annot"><span class="annottext">UniqSet a
</span><a href="#local-6989586621681023684"><span class="hs-identifier hs-var">neighbors</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-612"></span><span>
</span><span id="line-613"></span><span class="hs-comment">-- | Intersect two associations.</span><span>
</span><span id="line-614"></span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#intersectAssoc"><span class="hs-identifier hs-type">intersectAssoc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Assoc"><span class="hs-identifier hs-type">Assoc</span></a></span><span> </span><span class="annot"><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#Store"><span class="hs-identifier hs-type">Store</span></a></span><span>
</span><span id="line-615"></span><span id="intersectAssoc"><span class="annot"><span class="annottext">intersectAssoc :: Assoc Store -&gt; Assoc Store -&gt; Assoc Store
</span><a href="GHC.CmmToAsm.Reg.Graph.SpillClean.html#intersectAssoc"><span class="hs-identifier hs-var hs-var">intersectAssoc</span></a></span></span><span> </span><span id="local-6989586621681023682"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023682"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621681023681"><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023681"><span class="hs-identifier hs-var">b</span></a></span></span><span>
</span><span id="line-616"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(UniqSet Store -&gt; UniqSet Store -&gt; UniqSet Store)
-&gt; Assoc Store -&gt; Assoc Store -&gt; Assoc Store
forall elt1 elt2 elt3 key.
(elt1 -&gt; elt2 -&gt; elt3)
-&gt; UniqFM key elt1 -&gt; UniqFM key elt2 -&gt; UniqFM key elt3
</span><a href="GHC.Types.Unique.FM.html#intersectUFM_C"><span class="hs-identifier hs-var">intersectUFM_C</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UniqSet Store -&gt; UniqSet Store -&gt; UniqSet Store
forall a. UniqSet a -&gt; UniqSet a -&gt; UniqSet a
</span><a href="GHC.Types.Unique.Set.html#intersectUniqSets"><span class="hs-identifier hs-var">intersectUniqSets</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023682"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc Store
</span><a href="#local-6989586621681023681"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-617"></span></pre></body></html>